Converting data types: Date, Integer

prasslprassl Member Posts: 24
Good morning everybody,

I would please need your help to sort out a little problem:
I am automatically generating file names in NAV 4.0 for external files which should look like this:

Date_SeqNR_Name.Extension e.g. 20060426_01_Test.txt

Problem is: I cannot combine the string-parts as Date is Type Date, SeqNr is Type Integer and Name + Extension are Strings. (Text)

Is there any way of converting data types in C/AL ? Like the parsing e.g. in Java ?
sorry, maybe my question is really simple, but I couldn t find a solution for it yet...

many thanks in advance
cheers,
mp :|
... I am not a programmer, I just write code.

Answers

  • HalMdyHalMdy Member Posts: 429
    Better is to decompose the date using the fct DATE2DMY() . See the online help for detail.

    Withe that fct, you could make something like :

    FileName := STRSUBSTNO('%1%2%3_ .......',DATE2DMY(WORKDATE,3),
    DATE2DMY(WORKDATE,2),
    ..... );
  • KowaKowa Member Posts: 925
    Look for the FORMAT ( Number into Text ) and the EVALUATE(Text into Number) functions in the C/SIDE online help
    Kai Kowalewski
  • David_CoxDavid_Cox Member Posts: 509
    Try this, it is a way of formatting dates how you want them

    // MyStr := FORMAT(TODAY,0,'<Day,2><Month,2><Year,2>');
    // MESSAGE(FORMAT(TODAY,0,'<Day,2><Month,2><Year,2>'));

    If you need to add a special space character say underscore you can use it like this
    // MyStr := FORMAT(TODAY,0,'<Day,2>_<Month,2>_<Year,2>');

    So yours would be
    MyStr := STRSUBSTNO('%1_ %2_%3.txt',FORMAT(TODAY,0,'<Year,4><Month,2><Day,2>'),FileCounter,Filename);
    Giving 20060427_1_Myfile.txt
    Analyst Developer with over 17 years Navision, Contract Status - Busy
    Mobile: +44(0)7854 842801
    Email: david.cox@adeptris.com
    Twitter: https://twitter.com/Adeptris
    Website: http://www.adeptris.com
  • prasslprassl Member Posts: 24
    problem solved the way HalMdy and David Cox suggested
    works fine \:D/

    thank you so much !
    cheers, manu :mrgreen:
    ... I am not a programmer, I just write code.
Sign In or Register to comment.