Skip to content

Latest commit

 

History

History
60 lines (41 loc) · 1.76 KB

datetimetoticks.md

File metadata and controls

60 lines (41 loc) · 1.76 KB
title titleSuffix description author ms.author ms.reviewer ms.service ms.subservice ms.topic ms.devlang ms.date ms.custom
DateTimeToTicks
Azure Cosmos DB for NoSQL
An Azure Cosmos DB for NoSQL system function that returns the number of ticks, or 100 nanoseconds, since the Unix epoch.
jcodella
jacodel
sidandrews
cosmos-db
nosql
reference
nosql
02/27/2024
query-reference

DateTimeToTicks (NoSQL query)

[!INCLUDENoSQL]

Converts the specified DateTime to ticks. A single tick represents 100 nanoseconds or 0.000000001of a second.

Syntax

DateTimeToTicks(<date_time>)

Arguments

Description
date_time A Coordinated Universal Time (UTC) date and time string in the ISO 8601 format YYYY-MM-DDThh:mm:ss.fffffffZ.

Note

For more information on the ISO 8601 format, see ISO 8601.

Return types

Returns a signed numeric value, the current number of 100-nanosecond ticks that have elapsed since the Unix epoch (January 1, 1970).

Note

For more information on the Unix epoch, see Unix time.

Examples

The following example measures the ticks since the date and time May 19, 2015 12:00 UTC.

:::code language="nosql" source="~/cosmos-db-nosql-query-samples/scripts/datetimetoticks/query.sql" highlight="2":::

:::code language="json" source="~/cosmos-db-nosql-query-samples/scripts/datetimetoticks/result.json":::

Remarks

  • This function returns undefined if the date and time isn't a valid ISO 8601 date and time string.
  • This function doesn't use the index.

Related content