ClickHouse/src/Functions/toDaysSinceYearZero.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

27 lines
955 B
C++
Raw Normal View History

#include <DataTypes/DataTypesNumber.h>
#include <Functions/DateTimeTransforms.h>
2023-09-22 13:13:55 +00:00
#include <Functions/FunctionDateOrDateTimeToSomething.h>
#include <Functions/FunctionFactory.h>
namespace DB
{
2023-09-22 13:13:55 +00:00
using FunctionToDaysSinceYearZero = FunctionDateOrDateTimeToSomething<DataTypeUInt32, ToDaysSinceYearZeroImpl>;
REGISTER_FUNCTION(ToDaysSinceYearZero)
{
2023-09-21 14:16:03 +00:00
factory.registerFunction<FunctionToDaysSinceYearZero>(FunctionDocumentation{
.description = R"(
2023-09-22 11:52:02 +00:00
Returns for a given date or date with time, the number of days passed since 1 January 0000 in the proleptic Gregorian calendar defined by ISO 8601.
2023-09-10 12:55:15 +00:00
The calculation is the same as in MySQL's TO_DAYS() function.
)",
2023-09-21 14:16:03 +00:00
.examples{{"typical", "SELECT toDaysSinceYearZero(toDate('2023-09-08'))", "713569"}},
.categories{"Dates and Times"}});
2023-09-10 12:55:15 +00:00
/// MySQL compatibility alias.
factory.registerAlias("TO_DAYS", FunctionToDaysSinceYearZero::name, FunctionFactory::CaseInsensitive);
}
}