duration()

This function returns the duration between two dates b and a in time unit c.

Parameters


Parameter

Description

a

Date.

b

Date.

c

Unit (y, M, d, h, m, s, S).

Possible units for parameter "c"


Value

Time unit

milli or S

Milliseconds.

sec or s

Seconds.

min or m

Minutes.

hour or H

Hours.

day or d

Days.

month or M

Months.

year or y

Years.

Examples


Parameter a

Parameter b

Parameter c

Result

2010-03-01 00:00:00

2010-03-15 00:00:00

d

-14

2010-03-15 00:00:00

2010-03-01 00:00:00

d

14

2010-03-01 00:00:00

2010-03-15 00:00:00

h

-336

2010-03-15 00:00:00

2010-03-01 00:00:00

h

336