DateTime.FromFileTime

DateTime

Converts a Windows file time (100-nanosecond intervals since 1601-01-01) to a datetime value.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

DateTime.FromFileTime(fileTime as nullable number) as nullable datetime

Parameters

NameTypeRequiredDescription
fileTimenumberYesA 64-bit integer representing the number of 100-nanosecond intervals since January 1, 1601 (UTC).

Return Value

datetimeA datetime value corresponding to the given Windows file time, expressed in local time.

Remarks

DateTime.FromFileTime converts a Windows FILETIME value — the number of 100-nanosecond intervals since 00:00:00 UTC on January 1, 1601 — into a datetime value expressed in local time. This format appears in Windows registry entries, Active Directory attributes (such as lastLogon and pwdLastSet), NTFS file metadata, and some COM/OLE automation APIs.

The result is adjusted to the local timezone of the host environment, which means the same FILETIME value will produce different datetime results on machines in different timezones. To get a consistent UTC-anchored result, use DateTimeZone.FromFileTime instead, which returns a datetimezone with a +00:00 offset. If the input is null, the function returns null.

A FILETIME value of 0 represents midnight January 1, 1601 UTC. Large 64-bit integers are typical — for reference, the FILETIME for January 1, 2024 is approximately 133,478,016,000,000,000. Verify that your source data loads these as numbers (not text) before calling this function.

Examples

Example 1: Convert Windows FILETIME values to datetimes

#table(
    type table [Description = text, FileTime = number, AsDateTime = datetime],
    {
        {"Jan 15, 2024", 133500000000000000, DateTime.FromFileTime(133500000000000000)},
        {"Mar 6, 2024",  133550000000000000, DateTime.FromFileTime(133550000000000000)}
    }
)
Result
Description
FileTime
AsDateTime
1Jan 15, 2024133,500,000,000,000,0001/15/2024 8:20:00 AM
2Mar 6, 2024133,550,000,000,000,0003/6/2024 7:33:20 AM

Example 2: Convert a known file time value

#table(
    type table [FileTime = number, DateTime = datetime],
    {{132000000000000000, DateTime.FromFileTime(132000000000000000)}}
)
Result
FileTime
DateTime
1132,000,000,000,000,00010/26/2019 1:46:40 AM

Example 3: Safe conversion with null handling

#table(
    type table [UserID = text, LastLogonFileTime = number, LastLogon = datetime],
    {
        {"U001", 133500000000000000, DateTime.FromFileTime(133500000000000000)},
        {"U002", null,               null},
        {"U003", 133550000000000000, DateTime.FromFileTime(133550000000000000)}
    }
)
Result
UserID
LastLogonFileTime
LastLogon
1U001133,500,000,000,000,0001/15/2024 8:20:00 AM
2U002nullnull
3U003133,550,000,000,000,0003/6/2024 7:33:20 AM

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks