Options

Find day number from date

erugalathaerugalatha Member Posts: 120
Hi,

How do I find the number of the day from a date?

e.g.
Jan 1st = 001
Dec 31st = 365

Thanks for any help

Answers

  • KowaKowa Member Posts: 926
    Basically
    NoOfDay :=  MyDate - 311206D + 365;
    

    If you need the end of the fiscal year instead, Function FindEndOfFiscalYear in Codeunit 8 AccSchedManagement will provide this.
    CALCDATE('<CY>',TODAY)
    
    will return the last day of the year.
    Kai Kowalewski
  • erugalathaerugalatha Member Posts: 120
    Thanks a lot ... works great! :)
  • KowaKowa Member Posts: 926
    But don't forget that a leap year has 366 days :wink:
    You can evaluate this with :
    Year := DATE2DMY(Date, 3) + 2000; 
    IsLeapYear := (Year MOD 4 = 0) AND ((Year MOD 100 <> 0) OR (Year MOD 400 = 0));
    
    Kai Kowalewski
  • SteveOSteveO Member Posts: 164
    Alternatively:
    // Calculates the Number of Days that have occured since the start of the year
    NumDays := MyDate - CALCDATE('-CY', TODAY) + 1;
    


    Don't have to worry about leap years. :)
    This isn't a signature, I type this at the bottom of every message
Sign In or Register to comment.