# DATETIME function

The DATETIME function is a combination of DATE and TIME functions.

DATE returns the sequential serial number that represents a particular date.

TIME returns the decimal representation of the time with a value ranging from 0 (zero) to 0.99999999, representing the times from 0:00:00 (12:00:00 AM) to 23:59:59 (11:59:59 P.M.).

## Syntax

DATETIME(year,month,day,hour,minute,second)

Year    The year argument can be one to four digits. You cannot use a year before 1900. If year argument is between 0 (zero) and 1899, the value is added to 1900 to calculate the year. For example, DATETIME(108,1,2,n,n,n) returns the date as 39,449; which is the serial number representing January 2, 2008 (1900+108). If year argument is between 1900 and 9999, the value is used as the year. For example, DATETIME(2008,1,2,n,n,n) also returns the date as 39,449.

Month    is a number representing the month of the year. If month is greater than 12, month adds that number of months to the first month in the year specified. For example, DATETIME(2008,14,2,n,n,n) returns the serial number representing February 2, 2009.

Day    is a number representing the day of the month. If day is greater than the number of days in the month specified, day adds that number of days to the first day in the month. For example, DATETIME(2008,1,35,n,n,n) returns the serial number representing February 4, 2008.

Hour    is a number from 0 (zero) to 32767 representing the hour. Any value greater than 23 will be divided by 24 and the remainder will be treated as the hour value. For example, DATETIME(n,n,n ,27,0,0) returns the time as.125 or 3:00 AM.

Minute    is a number from 0 to 32767 representing the minute. Any value greater than 59 will be converted to hours and minutes. For example, DATETIME(n,n,n ,0,750,0) returns the time as .520833 or 12:30 PM.

Second    is a number from 0 to 32767 representing the second. Any value greater than 59 will be converted to hours, minutes, and seconds. For example, DATETIME(n,n,n ,0,0,2000) returns the time as .023148 or 12:33:20 AM

## Remarks

• Dates are stored as sequential serial numbers so they can be used in calculations. By default, December 31 1899 is serial number 1, and January 1, 2008 is serial number 39448 because it is 39,448 days after January 1, 1900.

• Time values are a portion of a date value and represented by a decimal number (for example, 12:00 PM is represented as 0.5 because it is half a day).

## Example

Month

Day

Hour

Minute

Second

Formula

Description (Result)

2006

12

1

12

45

25

=DATETIME([Year],[Month],[Day],[Hour],[Minute],[Second])

Serial number for the date and the decimal representation of the time of the day (39,052.5315393519)