K3 Documents

DateTime Manipulation

Updated on

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

Description:

Get Current Date Time

new Date()
Click to copy

Description:

Get Today's Date

CalendarUtil.truncateTime(new Date())
Click to copy

Description: 

Get Yesterday's Date

new Date(CalendarUtil.truncateTime(new Date()).getTime()-1000)
Click to copy

Description

Truncate Time

CalendarUtil.truncateTime({Date Field})
Click to copy

Description

Turn a Date into DateTime

new java.util.Date({Date Field}.getTime())
Click to copy

Description

End Of Month

CalendarUtil.endOfMonth({Date Field})
Click to copy

Description

Start Of Month

CalendarUtil.startOfMonth({Date Field})
Click to copy

Description

Start Of Year

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

Description

Parse String to date

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

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")
Click to copy

Description

Get Hours Between two dates

CalendarUtil.hoursBetween({Date1}, {Date2})
Click to copy

Description

Get Days Between two dates

CalendarUtil.daysBetween({Date1}, {Date2})
Click to copy

Description

Get Months Between two dates

CalendarUtil.monthsBetween({Date1}, {Date2})
Click to copy

Description

Get Years Between two dates

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