Hi,
In the database, in the column where you are saving the year, the datatype will be datatime in the format (YYYY-MM-DD)
and the default value of the year is 1900. So, when you give only date,, ie, for example:
DECLARE @time1 time(4) = '12:29:05.1234';
DECLARE @datetime2 datetime = @time1
SELECT @datetime2 AS 'datetimevar2'
Then the output will be as follows:
datetimevar2
1900-01-01 12:29:05.123
Execute the following query:
DECLARE @datetime1 datetime = '12-23-51';
DECLARE @time1 time(4) = '11:10:05.1234';
DECLARE @datetime2 datetime = @time1
SELECT @datetime1 AS 'datetime1', @datetime2 AS 'datetimevar2'
For datetime column, if you mention the year as any value below 50 (49,48,47........),
then the year in the output will be 2019, 2048, .....
Whereas if you give the value for the year above 49, then the output for the year will be in 19's ie, 1950, 1951, 1985, ................
That is the reason when you entering the year as 98, in is getting stored as 1998 in database...
Mark as Answr if satisfied............
Thank You,
Shree M.
Kavya Shree Mandapalli
Kishore463, if this helps please login to Mark As Answer. | Alert Moderator