date formula

nostran
Member Posts: 106
hi,
i've got a date , shipmentdate. i've got safety lead time that i get from the item card.
i need to subtract the lead time from the shipment date. the shipmentdate is a dateformula format, so is my lead time.
what i'm want to do is actually
b:= ShipmentDate - Leadtime
but i'm stuck with the syntax
i tried
DateToOrder := CALCDATE(Item."Safety Lead Time", PeriodStartDate)
but i need to subtract item."safety Lead Time" from PerodStartDate but can't figure out how :oops:
thanks
i've got a date , shipmentdate. i've got safety lead time that i get from the item card.
i need to subtract the lead time from the shipment date. the shipmentdate is a dateformula format, so is my lead time.
what i'm want to do is actually
b:= ShipmentDate - Leadtime
but i'm stuck with the syntax
i tried
DateToOrder := CALCDATE(Item."Safety Lead Time", PeriodStartDate)
but i need to subtract item."safety Lead Time" from PerodStartDate but can't figure out how :oops:
thanks
0
Comments
-
Nostran
The call to calculate a new date from an existing date with a Date Formula is 100% correct. The problem here is not a syntax error, but rather a logical error.
Think about it logically: You enter your "Safety Lead Time" on the Item Card as, for instance: 5D (5 Days).
You then try to calculate the new date using:
DateToOrder := CALCDATE(Item."Safety Lead Time", PeriodStartDate)
Instead of subtracting % days from the PeriodStartDate, the system will add 5 Days.
There are 2 solutions to this:
1. The best solution is to construct a new "Safety Lead Time" before you calculate the date. Convert the DateFormula to Text, test for a minus sign as the first character, if no minus sign was found, add one to the beginning of the string. Convert the new text to a DateFormula using EVALUATE and then calculate the new date.
2. Add code to the OnValidate trigger of the "Safety Lead Time" field to ensure users enter a negative date formula. (Only do this if you don't utilise any other features that uses the Safety Lead Time functionality.
/Wiechardt0 -
Or you could try...
DateToOrder := CALCDATE('-'+Format(Item."Safety Lead Time"),PeriodStartDate);
This should work.Zarryn0
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