#### Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

Options

# Find day number from date

Member Posts: 120
edited 2006-11-17
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

• Options
Member Posts: 920
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
• Options
Member Posts: 120
Thanks a lot ... works great!
• Options
Member Posts: 920
But don't forget that a leap year has 366 days
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
• Options
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