How to Convert text to Date & Decimal

raveendran.sraveendran.s Member Posts: 119
Hi,
I need to convert a text value to a Date & also text to decimal. Please help me how to do it[/b]
--
Regards,
Raveendran.BS

Comments

  • easabanganeasabangan Member Posts: 114
    Text to date
    txtVariable := '010107';
    EVALUATE(dateVariable, txtVariable);
    MESSAGE(FORMAT(dateVariable));
    

    Text to decimal
    txtVariable := '123.45';
    EVALUATE(decimalVariable, txtVariable);
    MESSAGE(FORMAT(decimalVariable));
    
    No future at CPI
  • kinekine Member Posts: 12,562
    I will just correct the code to "clean" code... ;-):
    txtVariable := '010107';
    EVALUATE(dateVariable, txtVariable);
    MESSAGE('%1',dateVariable);
    

    and
    txtVariable := '123.45';
    EVALUATE(decimalVariable, txtVariable);
    MESSAGE('%1',decimalVariable); 
    

    And do not forget that somewhere is the '.' used as decimal point and somewhere ','. And that somewhere you can have ',' as thousand separator.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • AsallaiAsallai Member Posts: 141
    I'd like to note, you can catch the exception, for example:
    IF EVALUATE(dateVar,txtVAR) THEN ;
    
    I think at this point you can catch the process if the convert does not work. :wink:
Sign In or Register to comment.