datetime()

Read(5404) 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

Option:

@m

Accurate to minute

@s

Accurate to second

@h

Accurate to hour

Return value:  

Datetime value

Example:

 

A

 

1

=datetime(now())

2013-12-09 00:00:00

2

=datetime@m(now())

2013-12-09 16:56:00

3

=datetime@s(now())

2013-12-09 16:56:45

4

=datetime@h(now())

2013-12-09 16:00:00

Related functions:

date()

date(datetimeExp)

time(datetimeExp)

datetime()

time()

datetime()

Description:

Convert a string or long integer to datetime value.

Syntax:

datetime(string)

Convert string string into datetime value according to system-defined datetime format; return null if the conversion fails

datetime(string{, format }:loc)

Convert the data type of string to datetime type according to the format defined by format and return null if the conversion fails; 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; parameter loc is the language used in stringExp; the default is the system language

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

Parameter:

string

String

format

Format string

loc

Language name, which is case insensitive. The most commonly used languages are Chinese (zh) and English (en); see A.sort() to know other languages supported in esProc

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

Example:

 

A

 

1

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

2006-01-01 10:20:30

2

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

1972-12-28 10:23:43

3

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

2006-01-01 10:20:30

4

=datetime(12345)

1970-01-01 08:00:12

5

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

1982-08-09 12:12:12

6

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

2005-12-31 13:40:30

7

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

2005-12-31 13:40:30

8

=datetime("4 五月 2001 3:08 下午","d MMM yyyy h:mm a":"zh")

2001-05-04 15:08:00

Related function:

date()

time()

date(datetimeExp)

datetime(datetimeExp)

time(datetimeExp)