Date and Time Functions


DATE_DIFF_INYEAR

Calculates the difference between two dates in years.

number DATE_DIFF_INYEAR( datetime1, datetime2 )

Examples:

DATE_DIFF_INYEAR( "2013-12-1", "2012-12-1" ) //return the number 1

DATE_DIFF_INMON

Calculates the difference between two dates in months.

number DATE_DIFF_INMON( datetime1, datetime2 )

DATE_DIFF_INWEEK

Calculates the difference between two dates in weeks.

number DATE_DIFF_INWEEK( datetime1, datetime2 )

DATE_DIFF_INDAY

Calculates the difference between two dates in days.

number DATE_DIFF_INDAY( datetime1, datetime2 )

DATE_DIFF_INHOUR

Calculates the difference between two dates in hours.

number DATE_DIFF_INHOUR( datetime1, datetime2 )

DATE_DIFF_INMIN

Calculates the difference between two dates in minutes.

number DATE_DIFF_INMIN( datetime1, datetime2 )

DATE_DIFF_INSEC

Calculates the difference between two dates in seconds.

number DATE_DIFF_INSEC( datetime1, datetime2 )

DATE_SHIFT_YEAR

Subtracts/adds an amount of years from a date value.

datetime DATE_SHIFT_YEAR( datetime, num_years )

Examples:

DATE_SHIFT_YEAR( "2013-12-1", 3 ) //return the datetime "2016-12-1"

DATE_SHIFT_YEAR( "2013-12-1", -3 ) //return the datetime "2010-12-1"

DATE_SHIFT_MONTH

Subtracts/adds an amount of months from a date value.

datetime DATE_SHIFT_MONTH( datetime, num_months )

DATE_SHIFT_WEEK

Subtracts/adds an amount of weeks from a date value.

datetime DATE_SHIFT_WEEK( datetime, num_weeks )

DATE_SHIFT_DAY

Subtracts/adds an amount of days from a date value.

datetime DATE_SHIFT_DAY( datetime, num_days )

DATE_SHIFT_HOUR

Subtracts/adds an amount of hours from a date value.

datetime DATE_SHIFT_HOUR( datetime, num_hours )

DATE_SHIFT_MIN

Subtracts/adds an amount of minutes from a date value.

datetime DATE_SHIFT_MIN( datetime, num_minutes )

DATE_SHIFT_SEC

Subtracts/adds an amount of seconds from a date value.

datetime DATE_SHIFT_SEC( datetime, num_seconds )

DATE_YEAR

Gets the year field from a datetime value.

number DATE_YEAR( datetime )

DATE_MONTH

Gets the month field from a datetime value.

number DATE_MONTH( datetime )

DATE_DAY

Gets the day field from a datetime value.

number DATE_DAY( datetime )

DATE_HOUR

Gets the hour field from a datetime value.

number DATE_HOUR( datetime )

DATE_MINUTE

Gets the minute field from a datetime value.

number DATE_MINUTE( datetime )

DATE_SECOND

Gets the second field from a datetime value.

number DATE_SECOND( datetime )

DATE_WEEKDAY

Gets the weekday field from a datetime value.

number DATE_WEEKDAY( datetime )