Date field, calculations

Client has a need to display or calculate a date for 6 months or 1 year after an existing date value in a Date field.

Is there a way to accomplish this?

Norman

Hi ncheng!
There are two ways.

  1. Using Automatic Calculation

DATE_FORMAT function looks good.

https://help.cybozu.com/en/k/user/autocalc.html

but times must be specified in seconds like this.
DATE_FORMAT(datetime + (60*60*24*365),“YYYY-MM-dd”,“system”)

 

  1. Using Moment.js

You can do this by Using JavaScript customize.

Please see the details below.
“Moment.js - customize date formats”
https://developer.kintone.io/hc/en-us/articles/115002348967

Note that the DATE_FORMAT function is only available for the calculation option on text fields, and that the output is text (and not in a date format).
You can also do something similar with the Calculated field - if you input the formula mydatefield + (60*60*24*365) , this will output the date after 60 days, but in the number of seconds, like  1492409700. You can change the display format for this number though to display a date format instead of this number. Note though, that this also is not actually a date (it’s just displayed as a date), so you won’t be able to include it in reminders.

If your main objective though is to send out reminders, you can go to the Reminder Notifications in your App Settings, Ass a new trigger, select your original date field and select “60 days after” and select a desired time. You won’t need to deal with calculated fields in this case.

If you strictly need the output as a date, I would go with Masa’s option 2 - use Moment.js.
There’s an article explaining how to use it
https://developer.kintone.io/hc/en-us/articles/115002348967 

 

how to automatically calculate the month?

Hi Yuzana

Sorry, your question is a bit vague…what issue are your trying to resolve?