Dates and times
As one might anticipate, the representation of both a date and a time is possible within the M language. This data type is a datetime data type and exhibits similar properties to both date data types and time data types. In fact, since dates are simply whole numbers based upon a reference date and time is a decimal number reflecting the fractions of a day, a datetime data type can be represented as a decimal number, where the whole number portion represents the date and the decimal portion represents the time. For example, the following expression returns noon on February 14th (2/14/2024 12:00:00 PM
):
DateTime.From(45336.5)
The individual components of date and time can be extracted from a datetime data type using the DateTime.Date
and DateTime.Time
functions. Alternatively, the DateTime.ToRecord
function returns a record with field/value pairs for Year
, Month
, Day
, Hour
, Minute
, and Second
.
Similar to dates and times, a constructor is available for the...