How sum Dateformula fields - Another question!!

Leroy
Member Posts: 199
Hello again, I'm doing operations with dates and, for example, I've two Dateformula fields. I've created a Dateformula variable and I want that it shows the sum of the other two dataformula fields, but I can't. I put:
prob:=((FORMAT("Field1"))+(FORMAT("Field2")));
Field1 is 3D
Field2 is 4D
But the result is that prob shows 3D4D, it should be the sum of that days, 8D. How can I do that?.
Thanks in advance.
prob:=((FORMAT("Field1"))+(FORMAT("Field2")));
Field1 is 3D
Field2 is 4D
But the result is that prob shows 3D4D, it should be the sum of that days, 8D. How can I do that?.
Thanks in advance.
0
Comments
-
Leroy wrote:Hello again, I'm doing operations with dates and, for example, I've two Dateformula fields. I've created a Dateformula variable and I want that it shows the sum of the other two dataformula fields, but I can't. I put:
prob:=((FORMAT("Field1"))+(FORMAT("Field2")));
Field1 is 3D
Field2 is 4D
But the result is that prob shows 3D4D, it should be the sum of that days, 8D. How can I do that?.
Thanks in advance.
You need to do it insteps.Date1 := CALCDATE("Field1",Startdate); Date2 := CALCDATE("Field2",Date2);
You can try adding etc. but always you wil find an exception that will not work.
CalcDate is what is know in Mathematics as a non continuous function , and thus does not have an inverse. In mathematics this limits what you can and can't do with it. I have seen such things as:evaluate(NewDateForm,format('%1+%2',Field1,Field2));
But at some stage it will fail and you will not find out until someone shows that the report is wrong.David Singleton0 -
Ok; thanks for help and information; I'll try it.
Thank you very much.0 -
Hello again; I've prove it and it works well, thank you!!!, but, if I want to subtraction it?, I mean, I've put for example:
prob:=CALCDATE("field1","field2");
And it sums correctly, field1 is a Dateformula field and field2 is a Date field, the prob variable is also a Date field. If field1 i 3D and field2 is 30/01/09 it shows me 2/02/09 that is correct, but if I want to subtraction it, it should show 27/01/09. How I can do it?.
Thanks for help in advance.0 -
And what you will do with e.g. formulas like '<-CM-1D>' and e.g. '<+CM+2M>'??? You cannot just work with the formulas like with numbers. You will get different results and + and - is not commutable in this "calculation".0
-
Thanks for reply. In my case always will be in "days". But, if it is not possible by this way, do you know if there is another way to do it?, I need to subtraction this.
Many thanks in advance.0 -
Than it is better to collect just "number of days" from the user instead the dataformula and construct the formula through something like:
MyDate := CALCDATE('<'+FORMAT(NoOfDays1-NoOfDays2)+'D>',FromDate);
0 -
Thanks for reply. What is "FromDate " please?.
Thanks.0 -
It is some date from which you want to calc the target date when you know how many days you want to subtract or add. E.g. TODAY, Document Date etc.0
-
Ok, thanks for reply. I'll try it.
Thanks you very much for help.0 -
Leroy wrote:Thanks for reply. In my case always will be in "days". But, if it is not possible by this way, do you know if there is another way to do it?, I need to subtraction this.
Many thanks in advance.
Did you read y reply above?David Singleton0 -
Hello 2009. I'm ashamed to say that I have just completed writing such a function to add 2 dateformulas together. A solid 2 and a half pages of code and half a day of creative messy string parsing for the world shatteringly important cosmetic effect of merging two date formulas instead of just adding simple form (eg +5D, -1W) to the end.
Currently the only way in testing I can break it is when the combined string exceeds the dateformula maximum length of 32, which is apparently a thing.
Pretty sure that no one is going to ask me for a copy of the code, which should stand as a testament to the futility of such a request.0 -
Oh, and no, my function will not intuitively handle operators without integers.0
-
Hello 2009. I'm ashamed to say that I have just completed writing such a function to add 2 dateformulas together. A solid 2 and a half pages of code and half a day of creative messy string parsing for the world shatteringly important cosmetic effect of merging two date formulas instead of just adding simple form (eg +5D, -1W) to the end.
Currently the only way in testing I can break it is when the combined string exceeds the dateformula maximum length of 32, which is apparently a thing.
Pretty sure that no one is going to ask me for a copy of the code, which should stand as a testament to the futility of such a request.0 -
What for? What's the purpose - if the date can be calculated in 2 steps in 2 separate lines of code? If this is your hobby then that's OK, but I'd be personally p***ed off as your employer, or your customer if you try to charge me for someting like thisSlawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
Slawek_Guzek wrote: »What for? What's the purpose - if the date can be calculated in 2 steps in 2 separate lines of code? If this is your hobby then that's OK, but I'd be personally p***ed off as your employer, or your customer if you try to charge me for someting like this
Oh, the customer was quite adamant. I told them and the consultant no many times.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