DateTime.From
Converts a value, such as a date, a time zone value or text, to a date and time.
DateTime.From(value as any, optional culture as nullable text) as nullable datetimeReturns: The date and time, or null when the input is null.
What it does
DateTime.From turns a value into a date with a time of day. It is most useful for a date that needs a time added, or for a time zone value that must be shown as a plain local date and time. Use it when the time matters, such as the timestamp of a payment or the approval time of a journal. When only the date matters, Date.From is simpler.
Syntax and arguments
- value: a date, a datetime, a datetime with a time zone, or text that holds a date and time.
- culture (optional): the culture used to read text, such as "en-US".
Example
An accounts payable team wants the approval time of an invoice next to the date, so it can see whether approvals were made the same day as the invoice. The date is converted to a datetime at midnight, which is the usual base for a comparison.
let
Approvals = #table(type table [Invoice = text, ApprovedOn = date],
{{"INV1043", #date(2026, 10, 27)}, {"INV1044", #date(2026, 10, 29)}}),
WithTime = Table.AddColumn(Approvals, "ApprovedAt", each DateTime.From([ApprovedOn]), type datetime)
in
WithTime
INV1043 gets the timestamp October 27, 2026 at 00:00:00 and INV1044 gets October 29, 2026 at 00:00:00. A real approval time would come from the source system as a datetime, and it would replace this midnight value.
Example: a second, different use
Turn a date and time from a bank file into a single datetime column, for a payment that carries a separate date and time column.
Things to watch
- A date converted to a datetime has a time of midnight, which is a placeholder, not a real time. Do not use it to measure hours.
- Text must match the culture. Pass one for text from another country.
- A datetime with a time zone is converted to a plain local datetime. Check the time zone before you compare two timestamps.
- Null in gives null out.
In business terms
Audit trails, cut-off testing and approval timing all depend on exact timestamps. Keeping the time with the date, and knowing where it came from, is what lets an auditor test whether an entry was posted before the period closed.