In Transact SQL , you may define an object as
DateTime) using the
[DATETIMEFROMPARTS]) function like following:
DECLARE @myDate DATE=DATEFROMPARTS(1988,11,28) DECLARE @someMoment DATETIME=DATEFROMPARTS(1988,11,28,10,30,50,123)
The parameters you provide are Year, Month, Day for the
DATEFROMPARTS function and, for the
DATETIMEFROMPARTS function you will need to provide year, month, day, hour, minutes, seconds and milliseconds.
These methods are useful and worth being used because using the plain string to build a date(or datetime) may fail depending on the host machine region, location or date format settings.