Customer Portal

Comments 5

  • Avatar
    avackova
    0
    Comment actions Permalink
    Hello,
    you can use dateadd function, eg.:
    string time;
    long hours;
    long min;
    long sec;
    date newDate;

    // Transforms input record into output record.
    function transform() {
    time = date2str($0.field1,"hh:mm:ss");
    hours = str2num(substring(time,0,2));
    min = str2num(substring(time,3,2));
    sec = str2num(substring(time,6,2));
    newDate = dateadd(trunc(today()),hours, hour);
    newDate = dateadd(newDate,min,minute);
    $0.field1 := dateadd(newDate, sec, second) ;
    }
  • Avatar
    deshartman
    0
    Comment actions Permalink
    Thanks for the reply. Seems like a lot of work. Was kinda hoping there was a simple way.

    What about date2long for both, add them and then use some function to get a date from a long number? Is there such a function?

    Thanks
    Des
  • Avatar
    avackova
    0
    Comment actions Permalink
    Yes, you're right:
    //#TL
    long newDate;
    long zeroDate = date2long(str2date("0001-01-01","yyyy-MM-dd"));
    long now = date2long(trunc(today()));

    // Transforms input record into output record.
    function transform() {
    newDate = now + date2long(trunc_date($field1)) - zeroDate;
    $0.field1 := long2date(newDate);
    }
  • Avatar
    deshartman
    0
    Comment actions Permalink
    Sweet. That's better. Thanks for the help

    Des
  • Avatar
    twaller
    0
    Comment actions Permalink
    Hi deshartman,

    You can find an overview of our CTL functions at the following two sites:

    http://www.cloveretl.com/_upload/clover ... k/apf.html
    (which is a part of our on-line Users Manual)

    and

    http://wiki.cloveretl.org/doku.php?id=t ... _functions
    (part of our wiki pages).

    CloverETL also includes a new CTLFunctionsTutorial project demonstrating the use of individual CTL functions.

    Best regards,

    Tomas Waller

Please sign in to leave a comment.