Converting DateFormula to Integer!!!

HanenHanen Member Posts: 281
Hi,

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

Hanen TALBI

Comments

  • matteo_montanarimatteo_montanari Member Posts: 189
    Hi

    You can convert a datetime like a "delta" integer:

    something like:

    i := calcdate('<1M>', today) - today

    But if the calculation involve month, for example, can return strange result:

    If today is 22 of may, + 1 Month the int result is 31 days.
    But if today is 22 Feb. + 1 Month the int result is 28 days.

    Bye

    Matteo
    Reno Sistemi Navision Developer
  • HanenHanen Member Posts: 281
    Thanks but I have to get something like :

    2M --> 60
    45D --> 45
    2Y --> 720
    ....................

    Can you tel me how can I deal with that?

    Regards

    Hanen TALBI
  • SavatageSavatage Member Posts: 7,142
    Hanen wrote:
    Thanks but I have to get something like :
    2M --> 60
    45D --> 45
    2Y --> 720
    ....................
    Can you tel me how can I deal with that?

    as the post above describes - you're going to have problems with 2M since not all months are 30 days. If you need it to be 60 days you'll need to code that to 60 & 2Y = 730 not 720.
  • AlishaAlisha Member Posts: 217
    You need to apply the formula to today's date, and then do the calculation

    new date - today's

    This will give you an integer, but as you've been advised you won't get 60 days when using 2M, it depends on the number of days of that particular month...
Sign In or Register to comment.