Value property

DateTimeField.Value — Number

Represents the value of a date and time field.

If no formula is associated with this property, the date and time field is an input field that users use to enter and edit values. If a formula is associated with this property, the date and time field is an output field that displays a calculated value derived through the formula.

The value of a date and time field is a sequential serial number. The integer part of the number represents the number of days that have elapsed since December 31, 1899, and the fractional part represents the time of day. The number 10.75 represents the 10th of January, 1900, at 6 PM (18:00). (0.75 means that three quarters of a day have elapsed.)

Specialized date and time functions

There are many specialized date and time functions that can process and return sequential serial numbers. Here are some of the most useful date and time functions:

Read the full list.

Using regular functions and operators to process dates and times

As regular numbers, you can also use standard numeric functions and operators to process sequential serial numbers, as long as you keep in mind how dates and times are stored. Again, dates are stored as the integer part of the sequential serial number and times are stored as the fractional part. As such, September 30, 2021, at 6 AM is stored as 44469.25. (0.25 means that one quarter of a day has elapsed.)

We can use that information to combine the DATE and TIME functions to create a formula which returns the date and time above:

DATE(2021, 9, 30) + TIME(6, 0, 0)DATE(2021; 9; 30) + TIME(6; 0; 0)

The two sequential serial numbers produced by the DATE and TIME functions are simply added together to combine the date and time into a single sequential serial number.

To calculate the number of days between two dates, subtract one sequential serial number from another and take the absolute value of the result (to prevent the result from being negative):

ABS(DateTimeField1 - DateTimeField2)ABS(DateTimeField1 - DateTimeField2)

To remove the time portion from a sequential serial number, truncate the number:

TRUNC(DateTimeField1)TRUNC(DateTimeField1)

To remove the date portion from a sequential serial number, use this formula:

DateTimeField1 - TRUNC(DateTimeField1)DateTimeField1 - TRUNC(DateTimeField1)

Referencing date and time field values from formulas

When referencing a date and time field value from a formula, there is no need to write .Value,Value after the field name if a number is sought. These formulas are equivalent:

HOUR(DateTimeField1)HOUR(DateTimeField1)
HOUR(DateTimeField1.Value)HOUR(DateTimeField1,Value)

Above, the HOUR function is looking to extract the hour (0 through 23) from a sequential serial number. As DateTimeField1DateTimeField1 can return a number through its Value property, .Value,Value is implied.

Examples

HOUR(DateTimeField1)HOUR(DateTimeField1)

Returns the hour (0 through 23) from the value of DateTimeField1.

HOUR(DateTimeField1.Value)HOUR(DateTimeField1,Value)

Returns the hour (0 through 23) from the value of DateTimeField1. Writing out the Value property in formulas (by writing DateTimeField1.ValueDateTimeField1,Value) is rarely necessary.

DateField1 + TimeField1DateField1 + TimeField1

Returns a sequential serial number representing the date of DateField1 (configured to only allow dates to be entered, no times) and the time of TimeField1 (configured to only allow times to be entered, no dates).

WEEKDAY(DateTimeField1)WEEKDAY(DateTimeField1)

Returns the day of the week from DateTimeField1. If the field represents a Monday, 2 is returned.

ABS(DateTimeField1 - DateTimeField2)ABS(DateTimeField1 - DateTimeField2)

Returns the number of days between the two date and time fields.

TRUNC(DateTimeField1)TRUNC(DateTimeField1)

Returns a sequential serial number representing the date of DateTimeField1, with its time portion removed.

DateTimeField1 - TRUNC(DateTimeField1)DateTimeField1 - TRUNC(DateTimeField1)

Returns a sequential serial number representing the time of DateTimeField1, with its date portion removed.