How to calculate - Same day next year

ajhvdb
Member Posts: 672
My customer has a special calendar table. He wants a function to copy all records to the next year (but keep the same day).
monday: 1 september 2008 --> monday: 31 august 2009
etc.
friday: 5 september 2008 --> friday: 4 september 2009
etc.
Can i use calcdate for this?
monday: 1 september 2008 --> monday: 31 august 2009
etc.
friday: 5 september 2008 --> friday: 4 september 2009
etc.
Can i use calcdate for this?
0
Answers
-
Hi
Try using CALCDATE('+52W', YourDate)
Harjot0 -
Take a look at virtual table Date. Could be something like that...
DateRec.SETRANGE("Period Type",DateRec."Period Type"::Day); DateRec.SETRANGE("Period Start",CALCDATE('<CW + 1Y - 1W>',YourDate),CALCDATE('<CW + 1Y - 1D>'),YourDate); DateRec.SETRANGE("Period No.",GetPeriodNoOfYourDate);
"Money is likewise the greatest chance and the greatest scourge of mankind."0 -
-
ajhvdb wrote:This one? <CW + 1Y - 1W>
CW returns the last day of the current week.
I didn't test it. Maybe it'sDateRec.SETRANGE("Period Start",CALCDATE('<CW + 1Y - 1W + 1D>',YourDate),CALCDATE('<CW + 1Y>'),YourDate);
You should try it."Money is likewise the greatest chance and the greatest scourge of mankind."0 -
-
Terms = 1year = +52w
I tested it - If i enter an order today 10/02/2008 the due date is 10/01/2009
Terms = 1year = CW+1Y-1W
I tested it - If i enter an order today 10/02/2008 the due date is 09/28/2009
So it looks like your looking for +52W+1D0 -
Today (October 2 2008) is a Thursday. October 1, 2009 is also a Thursday. If I read the original question right, this is exactly what he's looking for.0
-
Hmm I guess - I was thinking he wanted 10/02/2008 & 10/02/2009.
Either way he has a choice.
i guess then +1y-1d give you the same answer
Here's a oldie
Navision Data Calculator
http://www.mibuso.com/dlinfo.asp?FileID=5140 -
I guess <+1Y - 1D> and <+52W -1D> will not work because of leap years.
That's why I refered to the Date table.
I think it should be something like that...Date.RESET; Date.SETRANGE("Period Type",Date."Period Type"::Day); Date.SETRANGE("Period Start",YourDate); Date.FINDFIRST; Date2.RESET; Date2.SETRANGE("Period Type",Date2."Period Type"::Day); Date2.SETRANGE("Period Start",CALCDATE('<CW + 1Y - 1W + 1D>',YourDate),CALCDATE('<CW + 1Y>',YourDate)); Date2.SETRANGE("Period No.",Date."Period No.); Date2.FINDFIRST;
Then Date2."Period Start" is your new Date. Next year, same day of week."Money is likewise the greatest chance and the greatest scourge of mankind."0 -
I tested +1y-1d worked for both regular & leap years unless we're talking about the DAY OF THE WEEK??0
-
Savatage wrote:I tested +1y-1d worked for both regular & leap years unless we're talking about the DAY OF THE WEEK??"Money is likewise the greatest chance and the greatest scourge of mankind."0
-
<+52W> is the answer in my opinion, that is always the same weekday, and 52 weeks is as close as you can get to one year. <+1Y> gives you the same date one year from the start date, which is always a different weekday. <-1D> will always give you problems in case of leapyears. Using the date table should always work, but is much more complex, for exactly the same result as <+52W>.
I guess it should be defined, something like "the date that has the same weekday, that is as close to 1 calendar year from the start date as possible".0 -
Thx, never thought of <+52W>
They are setting up a grow plan for plants. This needs to start the next year again on monday, ...0 -
Credit goes to:hs_mann wrote:Try using CALCDATE('+52W', YourDate)0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K 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
- 320 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