datetime()

Read(271) Label: datetime,

Here’s how to use datetime() function.

datetime( datetimeExp )

Description:

Adjust the precision of the datetime expression and return it.

Syntax:  

datetime(datetimeExp)

Note:  

The function adjusts the precision of datetimeExp and returns it. By default, the precision is the day.

Parameter:  

datetimeExp

Datetime value

Options:

@m

Measure to minute

@s

Measure to second

Return value:  

Datetime value

Example:

datetime(now())

2013-12-09 00:00:00

datetime@m(now())

2013-12-09 16:56:00

datetime@s(now())

2013-12-09 16:56:45

Related functions:

date()

date(datetimeExp)

time(datetimeExp)

datetime()

time()

datetime()

Description:

Convert the string or long integer to datetime value.

Syntax:

datetime(string{, format })

Convert the data type of string to datetime type according to the format defined by format; if parameter format doesn’t exist, the format of string of string type should be the same as the format of datatime value in configuration information

datetime(long)

Convert long of long integer type to datetime value

datetime(date,time)

Concatenate date type data and time type data into data of datetime type

datetime(y,m,d,h,m,s)

Convert y,m,d,h,m,s of integer type to datetime data

datetime(ym,d,h,m,s)

Convert integer ym, d, h, m, s into datetime data

Note:

The format of string should match format.

Parameters:

string

String

format

Format string

long

Long integer counted in microseconds

date

Date type

time

Time type

y

Positive integer, year

m

Positive integer, month

ym

6-bit positive integer interpreted as year and month

d

Positive integer, day

h

Positive integer, hour

m

Positive integer, minute

s

Positive integer, second

Return value:

Datetime type data

Example:

datetime("2006-01-01 10:20:30")

2006-01-01 10:20:30

datetime("12/28/1972 10:23:43","MM/dd/yyyy HH:mm:ss")

1972-12-28 10:23:43

datetime("2006-01-01 10:20:30:111")

2006-01-01 10:20:30

datetime(12345)

1970-01-01 08:00:12

datetime(date("1982-08-09"),time("12:12:12"))

1982-08-09 12:12:12

datetime(2006,01,01,-10,-20,30)

datetime(200601,01,-10,-20,30)

2005-12-31 13:40:30

2005-12-31 13:40:30

Related functions:

date()

time()

date(datetimeExp)

datetime(datetimeExp)

time(datetimeExp)