Date math rocks: What day of the year is today?
aztecconsulting
Member Posts: 55
I need to know which of the 365 (or 366) days of the year today is. I have searched for Julian Date but the one page I found with a formula is oftly complex. This conceptually should be east but I can't figure it out. Please help.
0
Comments
-
on http://www.mistupid.com/calendar/dayofyear.htm
if you view-> source from your browser you can see the formula they use to calculate the number.
maybe this can point you in the right direction.
& you can use this if you want to create something like the web page
http://www.mibuso.com/dlinfo.asp?FileID=518
Here is a formula for finding the day of the week for ANY date.
N = d + 2m + [3(m+1)/5] + y + [y/4] - [y/100] + [y/400] + 2
read this:
http://mathforum.org/library/drmath/view/55837.html
You can always search google for
"day number of the year formula"
or
"Julian Day Number Calculator"0 -
How about?
DayOfYear(MyDate : Date) : Integer EVALUATE(FirstDay,'12/31/' + FORMAT((DATE2DMY(MyDate,3)-1))); // -1 to get last day of previous year EXIT(MyDate - FirstDay);
Works for leap years too.
Steve0 -
SPost29 wrote:How about?
DayOfYear(MyDate : Date) : Integer EVALUATE(FirstDay,'12/31/' + FORMAT((DATE2DMY(MyDate,3)-1))); // -1 to get last day of previous year EXIT(MyDate - FirstDay);
Works for leap years too.
Steve
What's FirstDay? It's not a command I know of and the code doesn't work as is.0 -
Sorry for the confusion,
FirstDay is a local Variable of datatype Date
It could be called LastDay too, if that makes the code clearer
Steve0 -
With j1 as a boolean and jday as integer this worked like a champ!
j1:=EVALUATE(FirstDay,'12/31/' + FORMAT((DATE2DMY(today,3)-1)));
jday:=today-FirstDay;0 -
-
There is another cleaner solution that uses built in Navision functionality.
Format(today, 0, '<Weekday Text>')0 -
this function FORMAT(TODAY,0,'<weekday text>') returns the day name of the week, like Monday, Tuesday , etc. We were trying to find the day of the year like day 267 of 365.
steve0 -
oops, you're right... sorry, I should have read the posts more closely.0
-
-
elapseddays:=TODAY-CALCDATE('<CY>',CALCDATE('<-1Y>',TODAY));0
-
even simpler solution:
elapseddays:=TODAY-CALCDATE('<-CY>',TODAY)+1;here calcdate returns start of the year date (Jan 1st)0 -
Nice 0 -
:evil: :evil:
Sorry, but I'm tired to think about this: I need to obtain the first and the last day of the next year, starting from a given date...
e.g.: with 15/02/07 i need 01/01/08 and 31/12/08
It's not a difficult problem, but I'm thinkin' and thinkin' the same thins and I won't get out of this hell alone... :evil: :evil:
Thanks!0 -
Or like this:
GMAToDateCM := CALCDATE('<CY + 1Y>',ToDate); GMAFromDateCM := CALCDATE('<-CY + 1Y>',ToDate); or GMAFromDateCM := CALCDATE('<CY + 1D>',ToDate);0 -
ME:GMAFromDateCM := CALCDATE('<CY + 1Y + 1D - 1Y>',ToDate);
EUGENEGMAFromDateCM := CALCDATE('<CY + 1D>',ToDate);
what's wrong in my code? if i want I can writeGMAFromDateCM := CALCDATE('<CY + 1Y + 1M + 1D - 1Y - 1M + 8D - 8D>',ToDate);and that's right! #-o #-o #-o0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 328 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions