Options

about date format

bangswitbangswit 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

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

    Kashyap
  • Options
    bangswitbangswit 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
  • Options
    deprodepro Member Posts: 46
    bangswit
    Try to use function DMY2DATE.
    But you need to cut and covert to integer your string before.

    regards,
    Depro
  • Options
    bangswitbangswit 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?
  • Options
    vijay_gvijay_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.
  • Options
    bangswitbangswit 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)
  • Options
    vijay_gvijay_g Member Posts: 884
    on which trigger you are writing code and in dataport field what you have defined for this field?
  • Options
    bangswitbangswit 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
  • Options
    impotenceimpotence 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 ~~~
  • Options
    bangswitbangswit 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 ?
  • Options
    impotenceimpotence 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 ~~~
  • Options
    kash387kash387 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
  • Options
    bangswitbangswit Member Posts: 265
    yap!
    those codes working !!
    thanks all :)
  • Options
    bangswitbangswit 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
  • Options
    vaprogvaprog Member Posts: 1,130
    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.
  • Options
    bangswitbangswit 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
Sign In or Register to comment.