Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
    • Yandex Cloud Partner program
  • Blog
  • Pricing
  • Documentation
© 2025 Direct Cursus Technology L.L.C.
Yandex DataLens
    • Overview
    • Formula syntax
      • All Functions
        • Overview
        • BOOL
        • DATE
        • DATETIME
        • DATETIME_PARSE
        • DATE_PARSE
        • DB_CAST
        • FLOAT
        • GEOPOINT
        • GEOPOLYGON
        • INT
        • STR
        • TREE
      • Function Availability
    • Parameters
  • Audit Trails events
  1. Calculated fields
  2. Function reference
  3. Type conversion functions
  4. DATETIME

DATETIME

Written by
Yandex Cloud
Improved by
amatol
Updated at November 6, 2024

SyntaxSyntax

DATETIME( expression [ , timezone ] )

DescriptionDescription

Converts the expression expression to date and time format. When converting Date to DateTime, the time is set to '00:00:00'.
The date must be in the format YYYY-MM-DDThh:mm:ss or YYYY-MM-DD hh:mm:ss.
Numeric values are rendered as time in Unix time format or equal to the number of seconds elapsed since 00:00:00 on January 1, 1970, less the adjustments for leap seconds.

The date and time can be converted to the specified time zone when the timezone option is available. The timezone parameter must be specified in Region/Data_Zone format.

Argument types:

  • expression — Date | Datetime | Fractional number | Integer | String
  • timezone — String

Return type: Datetime

Note

Only constant values are accepted for the arguments (timezone).

Note

Argument timezone is available only for ClickHouse sources.

ExamplesExamples

DATETIME("2019-01-23 15:07:47") = #2019-01-23 15:07:47#
DATETIME("2019.01.02 03:04:05") = #2019-01-02 03:04:05#
DATETIME("2019-01-23") = #2019-01-23 00:00:00#
DATETIME(1576807650) = #2019-12-20 02:07:30#
DATETIME(1576807650.793) = #2019-12-20 02:07:30#
DATETIME(1576807650.793, 'Asia/Hong_Kong') = #2019-12-20 10:07:30#

Data source supportData source support

ClickHouse 21.8, Files, Google Sheets, Yandex Metrica, Microsoft SQL Server 2017 (14.0), MySQL 5.7, Oracle Database 12c (12.1), PostgreSQL 9.3, Yandex Documents, YDB.

Was the article helpful?

Previous
DATE
Next
DATETIME_PARSE
© 2025 Direct Cursus Technology L.L.C.