• Resolved mike1st

    (@mike1st)


    Hi there,

    cdate(x)….”If fieldname1 is a date field, and its value is 3/11/2013: cdate(fieldname1+10) would be 13/11/2013″…

    How to do + 1 year?

    CDATE(fieldname1 +???)

    Thanks)

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @mike1st

    1 Year = 365 days

    So, the equation would be: CDATE(fieldname1 + 365)

    Best regards.

    Thread Starter mike1st

    (@mike1st)

    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.
    Plugin Author codepeople

    (@codepeople)

    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.

    Thread Starter mike1st

    (@mike1st)

    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

    Plugin Author codepeople

    (@codepeople)

    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.

    Thread Starter mike1st

    (@mike1st)

    Thanks.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘CDATE () +1 year?’ is closed to new replies.