Skip to content

Latest commit

 

History

History
56 lines (38 loc) · 1.59 KB

todatetime-function.md

File metadata and controls

56 lines (38 loc) · 1.59 KB
title description ms.reviewer ms.topic ms.date
todatetime()
Learn how to use the todatetime() function to convert the input expression to a datetime value.
alexans
reference
01/08/2024

todatetime()

Converts the input to a datetime scalar value.

Note

When possible, use datetime literals instead.

Syntax

todatetime(value)

[!INCLUDE syntax-conventions-note]

Parameters

Name Type Required Description
value scalar ✔️ The value to convert to datetime.

Returns

If the conversion is successful, the result will be a datetime value. Else, the result will be null.

Example

The following example converts a date and time string into a datetime value.

[!div class="nextstepaction"] Run the query

print todatetime("2015-12-31 23:59:59.9")

The following example compares a converted date string to a datetime value.

[!div class="nextstepaction"] Run the query

print todatetime('12-02-2022') == datetime('12-02-2022')

Output

print_0
true