This page is part of the Calculated Fields Form's documentation (a WordPress Plugin). The Date Time Module is part of the Developer Version of the Calculated Fields Form.

Date Time Module

The Date Time module includes a group of operations to manage dates and times.

Operation Description Demo
DATEOBJ(x,y)

Get the date object from an string representation of date. DATEOBJ( date_string, format )

DATEOBJ('2013-05-21', 'yyyy-mm-dd')
Result: date object

YEAR(x,y)

Get the year from an string representation of date. YEAR( date_string, format )

YEAR('2013-05-21', 'yyyy-mm-dd')
Result: 2013

MONTH(x,y)

Get the month from an string representation of date. MONTH( date_string, format )

MONTH('2013-05-21', 'yyyy-mm-dd')
Result: 5

DAY(x,y)

Get the days from an string representation of date. DAY( date_string, format )

DAY('2013-05-21', 'yyyy-mm-dd')
Result: 21

WEEKDAY(x,y)

Get the week day from an string representation of date. WEEKDAY( date_string, format )

WEEKDAY('2013-10-27', 'yyyy-mm-dd')
Result: 1 Sunday is the day number one

WEEKNUM(x,y)

Get the week number from an string representation of date, a year has 53 weeks.WEEKNUM( date_string, format )

WEEKNUM('2013-10-27', 'yyyy-mm-dd')
Result: 43

HOURS(x,y)

Get hours from an string representation of datetime. HOURS( datetime_string, format )

HOURS('2013-10-27 01:21', 'yyyy-mm-dd hh:ii')
Result: 1

MINUTES(x,y)

Get minutes from an string representation of datetime. MINUTES( datetime_string, format )

MINUTES('2013-10-27 01:22', 'yyyy-mm-dd hh:ii')
Result: 22

SECONDS(x,y)

Get seconds from an string representation of datetime. SECONDS( datetime_string, format )

SECONDS('2013-10-27 01:22:56', 'yyyy-mm-dd hh:ii:ss')
Result: 56

NOW()

Get a date object with the current day-time information. NOW()

NOW()
Result: 2013-10-27 01:42:19

TODAY() Get a date object with the current day information, without the time part.TODAY()

 

DATEDIFF(date_one, date_two, date_format, return)

Get the difference between two dates strings representation

DATEDIFF(date_one, date_two, date_format, return)

The function return an object, whose value depends of argument 'return'

Possible values of return argument:
d - return the number of days between two dates
m - return the number of months between two dates, and remaining days
y - return the number of years between two dates, remaining months, and remaining days

DATEDIFF('2013-10-27', '2012-06-22', 'yyyy-mm-dd', 'y')['months']
Result: 5

DATETIMESUM(date_string, format, number, to_increase)

Increases the date-time string representation in the number of seconds, minutes, hours, days, months, or years, passed as parameter.

DATETIMESUM( date_string, format, number, to_increase )

DATETIMESUM('2013-10-27', 'yyyy-mm-dd', 5, 'd')

Result: The date object representation of 2013/11/01

GETDATETIMESTRING(datetime_object, format)

Returns the string representation of a date object

GETDATETIMESTRING( datetime_object, format )

GETDATETIMESTRING(TODAY(), 'yyyy-mm-dd')
Result: 2013-10-27