2024-03-05 11:11:18 +00:00
|
|
|
#include <Common/FunctionDocumentation.h>
|
2024-03-01 13:14:44 +00:00
|
|
|
#include <Functions/DateTimeTransforms.h>
|
|
|
|
#include <Functions/FunctionDateOrDateTimeToSomething.h>
|
2024-03-05 11:11:18 +00:00
|
|
|
#include <Functions/FunctionFactory.h>
|
2024-03-01 13:14:44 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
using FunctionToMillisecond = FunctionDateOrDateTimeToSomething<DataTypeUInt16, ToMillisecondImpl>;
|
|
|
|
|
|
|
|
REGISTER_FUNCTION(ToMillisecond)
|
|
|
|
{
|
2024-03-05 11:11:18 +00:00
|
|
|
factory.registerFunction<FunctionToMillisecond>(
|
|
|
|
|
|
|
|
|
|
|
|
FunctionDocumentation{
|
|
|
|
.description=R"(
|
|
|
|
Returns the millisecond component (0-999) of a date with time.
|
|
|
|
)",
|
|
|
|
.syntax="toMillisecond(value)",
|
|
|
|
.arguments={{"value", "DateTime or DateTime64"}},
|
|
|
|
.returned_value="The millisecond in the minute (0 - 59) of the given date/time",
|
|
|
|
.examples{
|
|
|
|
{"toMillisecond", "SELECT toMillisecond(toDateTime64('2023-04-21 10:20:30.456', 3)", "456"}},
|
|
|
|
.categories{"Dates and Times"}
|
|
|
|
}
|
|
|
|
);
|
2024-03-01 13:14:44 +00:00
|
|
|
|
|
|
|
/// MySQL compatibility alias.
|
|
|
|
factory.registerAlias("MILLISECOND", "toMillisecond", FunctionFactory::CaseInsensitive);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|