Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Date Format

Author  Topic 

msrs

32 Posts

Posted - 2008-08-21 : 03:59:57
Hi all,

How to treat this date format in sql server '22-oct-00'any function is there to find out.(sql treat this year 00 as 2000 or 3000)


Thanks&Regards,

Msrs

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-08-21 : 04:00:58
select cast('22-oct-00' as datetime)

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

msrs

32 Posts

Posted - 2008-08-21 : 04:23:51

i am giving date format like this
select cast('22-oct-99' as datetime)
this will display :1999-10-22 00:00:00.000

Previous century

select cast('22-oct-20' as datetime) this will display :2020-10-22 00:00:00.000

present century
it will take the range from 0-49 Previous century
and 50-99 present century.



Thanks&Regards,

Msrs
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-21 : 04:27:36
quote:
Originally posted by msrs


i am giving date format like this
select cast('22-oct-99' as datetime)
this will display :1999-10-22 00:00:00.000

Previous century

select cast('22-oct-20' as datetime) this will display :2020-10-22 00:00:00.000

present century
it will take the range from 0-49 Previous century
and 50-99 present century.



Thanks&Regards,

Msrs


thats how sql server interprets it. have you had a look at books online reagrding cast & convert?

the below is from BOL

By default, SQL Server interprets two-digit years based on a cutoff year of 2049. That is, the two-digit year 49 is interpreted as 2049 and the two-digit year 50 is interpreted as 1950. Many client applications, such as those based on Automation objects, use a cutoff year of 2030. SQL Server provides the two digit year cutoff configuration option that changes the cutoff year used by SQL Server and allows for the consistent treatment of dates. We recommend specifying four-digit years.
Go to Top of Page
   

- Advertisement -