2023-09-08 13:27:24 +00:00
|
|
|
#include <DataTypes/DataTypesNumber.h>
|
|
|
|
#include <Functions/DateTimeTransforms.h>
|
2023-09-22 13:13:55 +00:00
|
|
|
#include <Functions/FunctionDateOrDateTimeToSomething.h>
|
2023-09-08 13:27:24 +00:00
|
|
|
#include <Functions/FunctionFactory.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2023-09-22 13:13:55 +00:00
|
|
|
using FunctionToDaysSinceYearZero = FunctionDateOrDateTimeToSomething<DataTypeUInt32, ToDaysSinceYearZeroImpl>;
|
2023-09-08 13:27:24 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
2023-09-08 13:27:24 +00:00
|
|
|
/// MySQL compatibility alias.
|
|
|
|
factory.registerAlias("TO_DAYS", FunctionToDaysSinceYearZero::name, FunctionFactory::CaseInsensitive);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|