Text to Date

shettarvikasshettarvikas Member Posts: 106
Hi,
How can we convert a text(having integer values) to date..

eg: Text := 20081224 (YYYYMMDD) to date 12/24/2008

same way need to conver text to Time
eg: Text = 192059 (hhmmss) to 19:20:59

Thanks & regards,
Vikas

Comments

  • ebsoftebsoft Member Posts: 81
    Hi,
    How can we convert a text(having integer values) to date..

    eg: Text := 20081224 (YYYYMMDD) to date 12/24/2008

    same way need to conver text to Time
    eg: Text = 192059 (hhmmss) to 19:20:59

    Thanks & regards,
    Vikas

    Simply..

    datef : variable date type

    EVALUATE(datef, COPYSTR(text,5,2)+'/'+COPYSTR(text,7,2)+'/'+COPYSTR(text,1,4));

    LOL
    Regards,
    Federico

    MBS Specialist since NAV 2.0
    My experiences on Linkedin
  • rajpatelbcarajpatelbca Member Posts: 178
    if your format of table will be remain same for every time then your can
    use following code.

    year := copystr(datetext,1,4);
    month := copystr(datetext,5,2);
    day := copystr(datetext,7,2);


    Evaluate(Dy,Day);
    evaluate(mm,month);
    evaluate(yy,year);

    DesireDate := DMY2Date(mm,dy,yy);

    for time


    TextToTime(VarText : Text[8]) : Time
    BaseVarTime := 111111T;
    TimeSeparator := COPYSTR(FORMAT(BaseVarTime),3,1);
    EVALUATE(VarTime,CONVERTSTR(VarText,':',TimeSeparator));
    EXIT(VarTime);
    Experience Makes Man Perfect....
    Rajesh Patel
  • shettarvikasshettarvikas Member Posts: 106
    hi..
    thanks both of u!!!
Sign In or Register to comment.