Hello @mike1st
1 Year = 365 days
So, the equation would be: CDATE(fieldname1 + 365)
Best regards.
Is it possible to add to the value of the year?
Adding 365 (or 366) days for my task will be incorrect.
For example, 01/01/2020 + 365 = 31/12/2020 (I need 01/01/2021). +10 years, +8 years … etc
-
This reply was modified 4 years ago by mike1st.
-
This reply was modified 4 years ago by mike1st.
Hello @mike1st
The recommend solution would be to use the “DATETIMESUM” operation into the Date Operations Module, distributed with the Developer and Platinum versions of the plugin (More information in the following link: https://cff.dwbooster.com/documentation#datetime-module)
GETDATETIMESTRING(DATETIMESUM(fieldname1, 'dd/mm/yyyy', 1, 'y'), 'dd/mm/yyyy')
If you are using the Free version, you need to manipulate the date components by yourself as follows:
(function(){
var p = CDATE(fieldname1, 'dd/mm/yyyy').split('/');
p[2] = p[2]*1+1;
return p.join('/');
})()
Best regards.
Thanks for answer!
(function(){
var p = CDATE(fieldname1, ‘dd/mm/yyyy’).split(‘/’);
p[2] = p[2]*1+1;
return p.join(‘/’);
})()
But, this function work incorrect. 29/02/2020—-> 29/02/2021, there is no date in 2021
Hello @mike1st
For this reason the preferred solution would be the use of the equation:
GETDATETIMESTRING(DATETIMESUM(fieldname1, 'dd/mm/yyyy', 1, 'y'), 'dd/mm/yyyy')
another alternative would be convert the value of date field into a javascript Date object, to call its methods, and then, transform again the result into a text:
(function(){
var d = new Date(fieldname1*86400000);
d.setFullYear(d.getFullYear()+1);
return CDATE(d/86400000, 'dd/mm/yyyy');
})()
I’m sorry, but the support service does not cover the implementation of the users’ projects (forms or formulas). If you need that I implement your project, do not hesitate in contact me through my private website: Customization
Best regards.