about date format

bangswit
bangswit Member Posts: 265
hi all... i have some questions about date format
1. how to read 20100614 to be read as a date?
2. if there is no data , i want it is filled by date of today
is it correct to be like this?
IF STRLEN(DocumentDateText)=0 THEN
                         EVALUATE(DocumentDate,'TODAY')
                      ELSE
                         EVALUATE(DocumentDate,DocumentDateText);


Thanks

Answers

  • vijay_g
    vijay_g Member Posts: 884
    use this....
    IF STRLEN(DocumentDateText)=0 THEN
                  DocumentDate := TODAY
               ELSE
                  EVALUATE(DocumentDate,DocumentDateText);
    
  • bangswit
    bangswit Member Posts: 265
    error mesage
    20100614 is not a valid date
  • kash387
    kash387 Member Posts: 111
    Check the system settings for your error message....!!!
    Thanks,

    Kashyap
  • bangswit
    bangswit Member Posts: 265
    kash387 wrote:
    Check the system settings for your error message....!!!
    there's nothing wrong with my system setting
    i just want to import data 20100614 to nav
  • depro
    depro Member Posts: 46
    bangswit
    Try to use function DMY2DATE.
    But you need to cut and covert to integer your string before.

    regards,
    Depro
  • bangswit
    bangswit Member Posts: 265
    depro wrote:
    bangswit
    Try to use function DMY2DATE.
    But you need to cut and covert to integer your string before.

    regards,
    Depro

    you mean separate with 3 strings ??
    20100614 become
    string1 --> 2010
    string2 --> 06
    string3 --> 14

    is it like this?
  • vijay_g
    vijay_g Member Posts: 884
    edited 2010-08-20
    what are you exactly doing is importing data or displaying report?
    need some clearification.
    describe your code here with trigger name.
  • bangswit
    bangswit Member Posts: 265
    vijay_g wrote:
    what are you exactly doing is importing data or displaying report?
    need some clearification.

    I am trying to import data
    the data is like this --> 20100614
    20100614 (YYYYMMDD)
  • vijay_g
    vijay_g Member Posts: 884
    on which trigger you are writing code and in dataport field what you have defined for this field?
  • bangswit
    bangswit Member Posts: 265
    vijay_g wrote:
    on which trigger you are writing code and in dataport field what you have defined for this field?

    i'm using report

    Report - OnPostReport()
    DocumentDate := 101310D;
    DocumentDateText1 := FORMAT(DocumentDate,0,'<Year4><Month,2><Day,2>');
    MESSAGE('%1',DocumentDateText1);
    --> it will show you 20101013

    so... how to reverse it?
    from 20101013 became read in date type
  • impotence
    impotence Member Posts: 20
    bangswit wrote:
    depro wrote:
    bangswit
    Try to use function DMY2DATE.
    But you need to cut and covert to integer your string before.

    regards,
    Depro

    you mean separate with 3 strings ??
    20100614 become
    string1 --> 2010
    string2 --> 06
    string3 --> 14

    is it like this?

    the easy way , create a function as follow ....
    e.g. ConvertDate(DocumentDateText : Text[50]) : Date
    EVALUATE(vYear,COPYSTR(DocumentDateText,1,4));
    EVALUATE(vMonth,COPYSTR(DocumentDateText,5,2));
    EVALUATE(vDay,COPYSTR(DocumentDateText,7,2));
    EXIT(DMY2DATE(vDay,vMonth,vYear));
    END is well that all is well ~~~
  • bangswit
    bangswit Member Posts: 265
    impotence wrote:
    bangswit wrote:
    depro wrote:
    bangswit
    Try to use function DMY2DATE.
    But you need to cut and covert to integer your string before.

    regards,
    Depro

    you mean separate with 3 strings ??
    20100614 become
    string1 --> 2010
    string2 --> 06
    string3 --> 14

    is it like this?

    the easy way , create a function as follow ....
    e.g. ConvertDate(DocumentDateText : Text[50]) : Date
    EVALUATE(vYear,COPYSTR(DocumentDateText,1,4));
    EVALUATE(vMonth,COPYSTR(DocumentDateText,5,2));
    EVALUATE(vDay,COPYSTR(DocumentDateText,7,2));
    EXIT(DMY2DATE(vDay,vMonth,vYear));

    is it valid for comp using DDMMYYYY and MMDDYYY ???
    or should i set the comp to be DDMMYYYY ?
  • impotence
    impotence Member Posts: 20
    if you want to using the other date format (DDMMYYYY or MMDDYYYY) , you should edit the code or create the other functions.
    END is well that all is well ~~~
  • kash387
    kash387 Member Posts: 111
    Hello,

    DMY2Date is a function that will create a date from you day, month and year.

    So the system will show you the date, in the format that is already set.

    So dont worry, if your format is set to DDMMYYYY or MMDDYYYY then the system will show you date like 14/06/10 or 06/14/10 respectively...!!!
    Thanks,

    Kashyap
  • bangswit
    bangswit Member Posts: 265
    yap!
    those codes working !!
    thanks all :)
  • bangswit
    bangswit Member Posts: 265
    how to get "NOW"??

    FORMAT(TODAY,0,'<Year4><Month,2><Day,2>') --> today
    how to get like this 01012010123055 -> date + time
    thanks
  • vaprog
    vaprog Member Posts: 1,173
    FORMAT(CURRENTDATETIME,0,'<Day,2><Month,2><Year4><Hours><Minutes>')
    
    Try to use YYYYMMDDHHmm rather than DDMMYYYYHHmm or MMDDYYYHHmm if you can. It is much more logical and sorts correctly.
  • bangswit
    bangswit Member Posts: 265
    vaprog wrote:
    FORMAT(CURRENTDATETIME,0,'<Day,2><Month,2><Year4><Hours><Minutes>')
    
    Try to use YYYYMMDDHHmm rather than DDMMYYYYHHmm or MMDDYYYHHmm if you can. It is much more logical and sorts correctly.
    yap i already use that format
    thanks