Question: title says it all. Internet is full of examples how to convert `FILETIME` to `TDateTime` but not the other way around.

Answer: 
```
function FileTimeToDateTime(AFileTime: FILETIME): TDateTime;
var
    li: ULARGE_INTEGER;
const
    OA_ZERO_TICKS = UInt64(94353120000000000);
    TICKS_PER_DAY = UInt64(864000000000);
begin
    // Convert a FILETIME (which is UTC by definition), into a UTC TDateTime.

    // Copy FILETIME into LARGE_INTEGER to allow UInt64 access without alignment faults.
    li.LowPart := AFileTime.dwLowDateTime;
    li.HighPart := AFileTime.dwHighDateTime;
    Result := (Real(li.QuadPart) - OA_ZERO_TICKS) / TICKS_PER_DAY;
end;

function DateTimeToFileTime(ADateTimeUTC: TDateTime): FILETIME;
var
    li: ULARGE_INTEGER;
const
    OA_ZERO_TICKS = UInt64(94353120000000000);
    TICKS_PER_DAY = UInt64(864000000000);
begin
    // Convert a UTC TDateTime into a FILETIME (which is UTC by definition).

    li.QuadPart := Round(ADateTimeUtc*TICKS_PER_DAY + OA_ZERO_TICKS);
    Result.dwLowDateTime := li.LowPart;
    Result.dwHighDateTime := li.HighPart;
end;

```

By avoiding a [`SYSTEMTIME`](https://learn.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-systemtime?redirectedfrom=MSDN), we avoid [losing precision in milliseconds.](https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsystemtimepreciseasfiletime)

The dwMilliseconds of SYSTEMTIME is, by definition, limited to 1 millisecond resolution.

```
| FILETIME                       | SYSTEMTIME              |
|--------------------------------|-------------------------|
| 100ns resolution               | 1,000,000 ns resolution |
| GetSystemTimeAsFileTime        | GetSystemTime           |
| GetSystemTimePreciseAsFileTime | n/a                     |
|                   -- FileTimeToSystemTime -->            |
|                  <-- SystemTimeToFileTime --             |

```

You should avoid `SYSTEMTIME`. The purpose of `SYSTEMTIME` is to decode a date/time into it's component parts for you:

* year, month, day, hour, minute, second, millisecond

Bonus Reading
-------------

* [**GetSystemTimeAsPreciseFileTime** function](https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsystemtimepreciseasfiletime)
* [**FILETIME** structure](https://learn.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-filetime)
* [**SYSTEMTIME** structure](https://learn.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-systemtime)
You can look at implementation of `ConvertDateTimeToFileTime` in `System.IOUtils`.
It is a private member of `TDirectory` record.
But you can use it as a reference in order to implement all you want in one function.