Date Functions

Date Add

Format – DateAdd(date,amount,unit)
Use this function when you do not want to hard code dates in your test steps.  There are two internal functions which are useful when managing dates:
TODAY will create a date and use the system date
NOW will create a date timestamp and use the system date

Examples:
{TODAY} – This will default to system date e.g. 2015-01-16
{NOW} – This will default to system date and time e.g. 2015-01-16 10:13:43.0
{DateAdd(TODAY,1)} – This will default to tomorrow e.g. 2015-01-17
{DateAdd(TODAY,”-1″)} – This will default to yesterday e.g. 2015-01-15
{DateAdd(TODAY,1,MONTH)} – This will add one month to current date e.g. 2015-02-16
{DateAdd(NOW,”-2″,HOUR)} – This will remove two hrs from current datetime e.g. 2015-01-16 08:15:27.0

 

Date Format

Format – DateFormat(date,output format,timezone)
Use this function when you need to convert a date into a specific format. For more information on available date formats you can review this information http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html

Examples:
{DateFormat()} – Defaults to system date in the format yyyy-MM-dd e.g. 2015-01-16
{DateFormat(TODAY,”MM-dd-YYYY”)} – Modify date format to be Month first e.g. 01-16-2015
{DateFormat(DateAdd(TODAY,5),”MM-dd-YYYY”)} – Use with other functions e.g. 01-21-2015
{DateFormat(NOW,”MM-dd-YYYY hh a zzzz”,”GMT”)} – Including a Timezone e.g. 01-16-2015 10 AM Greenwich Mean Time

 

Date Parse

Format – DateParse(DateString,InputFormat,OutputFormat)
Use this function when you would like to convert a date from a String into a Date.

Examples:
{DateParse(“2015-03-15”, “yyyy-MM-dd”)} – Will return this string as a date e.g. 2015-03-15
{DateParse(“2015-03-15”, “yyyy-MM-dd”,”MM-dd-yyyy”)} – Will return this string as a date and convert the date into a new format e.g. 03-15-2015

2017-05-12T11:35:04+00:00

Leave A Comment