Conversing DateFormula to Integer

klum
Member Posts: 102
Hi All,
I am working on Nav4.0SP3. I used search the forum already but I cannot find the exactly answer for my question...I have to apologize first if I do ask the same question..
My question is "How do converse DateFormula to Integer?"
For the example :
I have field called Duration with Dateformula DataType I need to converse this filed to be Month
Ex. If user put data = 18M I just need 18 and if user put data like this --> 1Y+6M+3D I have to converse to Month first and then converse to integer again...for get the value to compute...
I hope you understand my question...
Best Regards,
Wanvisa
I am working on Nav4.0SP3. I used search the forum already but I cannot find the exactly answer for my question...I have to apologize first if I do ask the same question..
My question is "How do converse DateFormula to Integer?"
For the example :
I have field called Duration with Dateformula DataType I need to converse this filed to be Month
Ex. If user put data = 18M I just need 18 and if user put data like this --> 1Y+6M+3D I have to converse to Month first and then converse to integer again...for get the value to compute...
I hope you understand my question...
Best Regards,
Wanvisa
0
Comments
-
Why do you want to extract values of the DateFormula?
I'm quite sure that the CALCDATE function can solve your problems.
Syntax:
NewDate := CALCDATE(DateExpression [, Date])
Where DateExpression can be a DateFormula, Text or Code.
Check on-line help for further information about the function.Regards
Peter0 -
There is no easy way how to split the date formula into parts. Do not forget that:
1) It is language-depending
2) Formulas can be complex - e.g. 'CY-2M-5D+1M+1Y-2W+2D+CM' - how do you want to convert that?
8)0 -
Function convert(DateFormula d) CurrMonth := DATE2DMY(TODAY, 2); CurrYear := DATE2DMY(TODAY, 3); NewDate := CALCDATE(TODAY, d); CalcMonth := DATE2DMY(NewDate, 2); CalcYear := DATE2DMY(NewDate, 3); IF CurrMonth < CalcMonth // 01-05 to 12-06 EXIT( (CalcMonth - CurrMonth + 1) * (CalcYear - CurrYear + 1) ) ELSE // 12-05 to 06-06 EXIT( (CurrMonth - CalcMonth + 1) * (CalcYear - CurrYear) );
Note: I didn't test it, just typed something out from my head, but I think it makes sense. It's at least a starting point and you can tweak it a little bit.0 -
Thanks guys....
I agree with you kine...so I just need some reference for explain to my consultant that we should use integer field it will be better in this case. However I will try code from matttrax that suggested to me..Thanks again
Best Regards,
Wanvisa0 -
klum wrote:Hi All,
I am working on Nav4.0SP3. I used search the forum already but I cannot find the exactly answer for my question...I have to apologize first if I do ask the same question..
My question is "How do converse DateFormula to Integer?"
For the example :
I have field called Duration with Dateformula DataType I need to converse this filed to be Month
Ex. If user put data = 18M I just need 18 and if user put data like this --> 1Y+6M+3D I have to converse to Month first and then converse to integer again...for get the value to compute...
I hope you understand my question...
Best Regards,
Wanvisa
Calcdate is a "non linear function", and as any mathematician will tell you, a non linear function can never be converted into a linear function.David Singleton0 -
David Singleton wrote:Calcdate is a "non linear function", and as any mathematician will tell you, a non linear function can never be converted into a linear function.
OK, before any "real" mathematicians catch me out, CALCDATE is a "non contiguous function" not a "non linear function", but the principle applies to both.
Hmm maybe its both.David Singleton0 -
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