Another date conversion

iballan
iballan Member Posts: 9
I need to impor dates like these in a general jounal

1. Nov 2010 13:55:59
31. Oct 2010 22:54:11

hov can i convert them to date in NAV. I want to use copystr, but i can't because the lenght is variable.

Comments

  • Luc_VanDyck
    Luc_VanDyck Member, Moderator, Administrator Posts: 3,633
    Use STRPOS to find out at what position the spaces are, and then use COPYSTR with that info to copy the data into your Day, Month, Year variables.
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • KYDutchie
    KYDutchie Member Posts: 345
    Those values look like datetimes.

    You can do:
    EVALUATE(YourDateTimeVar,yourTextvar);
    YourDateVar := DT2DATE(YourDateTimeVar);
    YourTimeVar := DT2Time(YourDateTimeVar);
    

    Where :
    YourTextVar is a variable of type Text(80)
    YourDateTimeVar is a variable of type DateTime
    YourDateVar is a variable of type Date
    YourTimeVar is a variable of type Time.

    See if this works for you,

    Regards,

    Willy
    Fostering a homeless, abused child is the hardest yet most rewarding thing I have ever done.
  • kriki
    kriki Member, Moderator Posts: 9,121
    something like:
    txtTheDateTime = '1. Nov 2010 13:55:59';
    
    EVALUATE(intDay,COPYSTR(txtTheDateTime,1,STRPOS(txtTheDateTime,'.') - 1));
    txtTheDateTime := COPYSTR(txtTheDateTime,1,STRPOS(txtTheDateTime,'.') + 1);
    CASE UPPERCASE(COPYSTR(txtTheDateTime,1,STRPOS(txtTheDateTime,' ') - 1)) OF // the second parameter of STRPOS is a blank!
      'JAN': LintMonth := 1;
      'FEB': LintMonth := 2;
      ...
    END;
    txtTheDateTime := COPYSTR(txtTheDateTime,1,STRPOS(txtTheDateTime,' ') + 1);
    EVALUATE(intYear,COPYSTR(txtTheDateTime,1,STRPOS(txtTheDateTime,' ') - 1)); // the second parameter of STRPOS is a blank!
    
    datTheDate := DMY2DATE(intDay,intMonth,intYear);
    
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!