TicksToDateTime (Azure Cosmos DB)

APPLIES TO: SQL API

Converts the specified ticks value to a DateTime.

Syntax

TicksToDateTime (<Ticks>)

Arguments

Ticks

A signed numeric value, the current number of 100 nanosecond ticks that have elapsed since the Unix epoch. In other words, it is the number of 100 nanosecond ticks that have elapsed since 00:00:00 Thursday, 1 January 1970.

Return types

Returns the UTC date and time ISO 8601 string value in the format YYYY-MM-DDThh:mm:ss.fffffffZ where:

Format Description
YYYY four-digit year
MM two-digit month (01 = January, etc.)
DD two-digit day of month (01 through 31)
T signifier for beginning of time elements
hh two-digit hour (00 through 23)
mm two-digit minutes (00 through 59)
ss two-digit seconds (00 through 59)
.fffffff seven-digit fractional seconds
Z UTC (Coordinated Universal Time) designator

For more information on the ISO 8601 format, see ISO_8601

Remarks

TicksToDateTime will return undefined if the ticks value specified is invalid.

Examples

The following example converts the ticks to a DateTime:

SELECT TicksToDateTime(15943368134575530) AS DateTime
[
    {
        "DateTime": "2020-07-09T23:20:13.4575530Z"
    }
]

Next steps