Hi All,
For dates, why do we need to check whether the year is less than 49 criteria. if it is less than 49 then 19 else 20?
Thanks
Technology Tips and News
Hi All,
For dates, why do we need to check whether the year is less than 49 criteria. if it is less than 49 then 19 else 20?
Thanks
Try
select case when YEAR(getdate())<49 then 19 else 20 end
Thanks for reply Hua,
My question is why do we need this criteria like if year < 2049 then 19__ else 20__?
I do not want to achieve this. I can achieve this :). But my question is, is it necessary to make such condition while building date condition.
Refer following link for to get more clarity.
http://social.msdn.microsoft.com/Forums/sqlserver/en-US/12c17b96-2260-459b-9b9e-dd6885469838/calculating-date-formate-with-a-number?forum=sqlgetstarted
can I make only that query as
DECLARE @dt VARCHAR(10) SET @dt = '201403' SELECT @dt, LEFT(@dt,2)+ '-'+RIGHT(@dt,2) + '-'+SUBSTRING(@dt,3,2)
Hi,
This criteria is required when using 2 digit year. i.e. When you user 2 digit year 35, it can either mean 1935 or 2035.
By default SQL Server uses 2049 as cut off, meaning that 01 to 49 are considered as 2001 to 2049.
and anything greater than 49 is considered as 1949, 1950...
Other applications may have different cut off year, so instead of using 2 digit always use 4 digit