K3 Documents

DateTime Manipulation

Updated Feb 03, 2021

Copy and Paste the following formula using your data where necessary.

Description:

Get Current Date Time

new Date()

Description:

Get Today's Date

CalendarUtil.truncateTime(new Date())

Description: 

Get Yesterday's Date

new Date(CalendarUtil.truncateTime(new Date()).getTime()-1000)

Description

Truncate Time

CalendarUtil.truncateTime({Date Field})

Description

Turn a Date into DateTime

new java.util.Date({Date Field}.getTime())

Description

End Of Month

CalendarUtil.endOfMonth({Date Field})

Description

Start Of Month

CalendarUtil.startOfMonth({Date Field})

Description

Start Of Year

new java.util.Date({Date Field}.getYear(),0,1)

Description

Parse String to date

CalendarUtil.parseDate({String Field}, "<DateFormat>")

Description

Parse Contract Month String to Date and convert date back to string in a specific format

CalendarUtil.format(CalendarUtil.parseDate({MMY}, "MMM-yy"),"yyyyMM")

Description

Get Hours Between two dates

CalendarUtil.hoursBetween({Date1}, {Date2})

Description

Get Days Between two dates

CalendarUtil.daysBetween({Date1}, {Date2})

Description

Get Months Between two dates

CalendarUtil.monthsBetween({Date1}, {Date2})

Description

Get Years Between two dates

CalendarUtil.yearsBetween({Date1}, {Date2})
Previous Article Replace Parts of a String
Next Article Round Decimal Values