Skip to content

Files

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Latest commit

Mar 14, 2025
01a9448 · Mar 14, 2025

History

History
68 lines (55 loc) · 1.81 KB

File metadata and controls

68 lines (55 loc) · 1.81 KB
title language
TO_DAYS
en

Description

Date calculation function, which is used to convert a date into a day value, that is, to calculate the total number of days from December 31, 0 AD (the base date) to the specified date.

Syntax

TO_DAYS([<datetime_value> | <date_value>])

Optional parameters

  1. <datetime_value>

datetime type datetime

  1. <date_value>

date type datetime

Example

Query how many days are there since October 7, 2007

select to_days('2007-10-07');
+---------------------------------------+
| to_days(cast('2007-10-07' as DATEV2)) |
+---------------------------------------+
|                                733321 |
+---------------------------------------+
select to_days('2007-10-07 10:03:09');
+------------------------------------------------+
| to_days(cast('2007-10-07 10:03:09' as DATEV2)) |
+------------------------------------------------+
|                                         733321 |
+------------------------------------------------+