DATETIME()

From Lianjapedia
Jump to: navigation, search

Purpose

Function to return current system date and time or a datetime from specified date and time values

Syntax

DATETIME([<expN1>, <expN2>, <expN3> [, <expN4> [, <expN5> [, <expN6>]]]])

See Also

AMPM(), CDOW(), CMONTH(), CTOD(), CTOT(), DATE(), DAY(), DAYS(), DMY(), DOW(), DTOC(), DTOM(), DTOS(), DTOV(), ELAPTIME(), EMPTY(), EPOCH(), GOMONTH(), HOUR(), HOURS(), LTOS(), MDY(), MINUTE(), MINUTES(), MONTH(), MTOD(), MTOS(), QUARTER(), SEC(), SECONDS(), SECS(), SET CENTURY, SET DATE, SET EPOCH, SET HOURS, SET MARK, SET SECONDS, STOD(), STR(), TIME(), TIMESTAMP(), TSTRING(), TTOC(), TTOD(), TYPE(), VAL(), VALIDTIME(), VTOD(), WEEK(), YEAR()

Description

The DATETIME() function returns the current system date and time as a datetime type. The display format of the date part of datetimes is affected by the SET CENTURY, SET DATE, SET EPOCH and SET MARK set commands. The SET SECONDS set command determines whether seconds are displayed in the time part of datetimes. The SET HOURS set command determines whether hours are shown in 24 hour format or in 12 hour format with AM | PM postfix.

The optional parameters can be used to specify numeric years, months, days, hours, minutes and seconds and return a valid corresponding datetime. If any date parameter is invalid, an empty datetime is returned. If any time parameter is invalid, an out of range error is generated.

Argument Description
<expN1> A valid number of years, -100 (1900) to 900 (2900)
<expN2> A valid number of months, 1 to 12
<expN3> A valid number of days, 1 to 31
<expN4> A valid number of hours, 0 to 23
<expN5> A valid number of minutes, 0 to 59
<expN6> A valid number of seconds, 0 to 59

Example

? datetime()
04/04/2004 11:54:45 AM
mdatetime = datetime()
? mdatetime
04/04/2004 11:54:45 AM
? type("mdatetime")
T
? datetime(4,4,4,4,4,4)
04/04/2004 04:04:04 AM
? datetime(4,4,4,14)
04/04/2004 02:00:00 PM