Convert integer into date

mcaverlymcaverly Member Posts: 26
I would like to convert an integer value into the date (ig. converting 16783, number of days since 1/1/1900. The result would be 12/12/1945) .

Thanks in advance for your advice and/or inputs.

Comments

  • matttraxmatttrax Member Posts: 2,309
    01011900D + 16783

    Although Navision says that that is 12/14/1945.
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    You can use CALCDATE to add x-number of days since a given date. But as the max. number that can be added is 9999, you'll have to do the calculation twice. The first time for the first 9999 days, the 2nd time for the remaining number of days:
    datDate := CALCDATE(STRSUBSTNO('<+%1D>',9999),DMY2DATE(1,1,1900));
    datDate := CALCDATE(STRSUBSTNO('<+%1D>',16783 - 9999),datDate);
    MESSAGE('1/1/1900 + 16783 days = %1',datDate);
    
    which gives 14/12/1945 as the result.
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • mcaverlymcaverly Member Posts: 26
    Thanks. It works.
  • DenSterDenSter Member Posts: 8,307
    matttrax wrote:
    01011900D + 16783
    Cool I didn't know it worked like that :mrgreen:
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    I feel stupid now :oops:
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • DenSterDenSter Member Posts: 8,307
    I feel stupid now :oops:
    Yeah so do I :mrgreen:
Sign In or Register to comment.