data type conversion integer to dateformula

micbsmicbs Member Posts: 6
Hi all!

I have a problem with data type conversion.

I have a BigInteger field that is the number of days of a lead time.
I have to insert it in another field, which is a dateformula field.

I tried something like:
EVALUATE(dateFormulaField, FORMAT(bigIntField) + 'D');
but it does not work. :(

Can someone help me?
Thank you!

Comments

  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    This works fine in a testcodeunit on 3.70
    bigIntField := 1;
    EVALUATE(dateFormulaField, FORMAT(bigIntField) + 'D');
    MESSAGE(FORMAT(dateFormulaField));
    

    Message is '1D' :-k
  • kinekine Member Posts: 12,562
    Do not forget, that Format insert Thousand separator... try to use
    EVALUATE(dateFormulaField, FORMAT(bigIntField,0,1) + 'D'); 
    
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • micbsmicbs Member Posts: 6
    Yes

    it gives the correct message, but when you execute record.INSERT;
    it says:
    ... Syntax error converting the varchar value '90☺' to a column of data type int.

    Any ideas?

    PS.: it doesn't word with integer fields (not only bigint ) as well.
  • kinekine Member Posts: 12,562
    ??? '90☺'??? What is it?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • micbsmicbs Member Posts: 6
    i don't know exactly, but I have an idea of that.

    If you look at the data in sql server, you will notice that the dateformula are not stored directly as they are.

    If you write 1D + 1Y, it doesn'y actually store that value, but it stores something like 1☺+1☺. The letters are stored in ascii codes like:

    ascii(1) for C, ascii(2) for D, 3 for WD, 4 for W, 5 for M, 6 for Q, 7 for Y.

    If you write the ascii code 1, 2 ,... you will see only strange characters like ☺.
  • kinekine Member Posts: 12,562
    Ok, I remember my post about this there: http://www.mibuso.com/forum/viewtopic.p ... =character
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • kinekine Member Posts: 12,562
    It seems that the dateFormulaField is not VarChar but Integer on the MS SQL. Check this, try to redefine the field (recreate) from Navision...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • micbsmicbs Member Posts: 6
    ok, I recreated the field and the whole table and it looks like working.

    Thank you all! :whistle:
  • HanenHanen Member Posts: 281
    Hi,

    How can I assign a field DateFormula to an integer field :(
    Anyone can help please?????
    Regards

    Hanen TALBI
  • kinekine Member Posts: 12,562
    You cannot.... how you want to retype e.g. "-CY+3M+1W-5D" as integer?

    And it is better to create new topic than answering in some which is 5 years old... ;-)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.