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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 simple conversion err

Author  Topic 

aakcse
Aged Yak Warrior

570 Posts

Posted - 2009-03-26 : 07:30:41
hi all

select convert(datetime,'29/2/09',103)

is giving conversion err..why?

regards,
aak

ayamas
Aged Yak Warrior

552 Posts

Posted - 2009-03-26 : 07:46:16
select convert(varchar(15),'29/02/09',103)
Go to Top of Page

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2009-03-26 : 07:47:20
2009 is not a leap year. 29 feb 09 is invalid. Moreover, you are using the styles incorrectly.

Try this,

select convert(datetime,'28/2/09',3)
select convert(datetime,'28/2/2009',103)
Go to Top of Page

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2009-03-26 : 07:48:49
quote:
Originally posted by ayamas

select convert(varchar(15),'29/02/09',103)



thats not the solution.
Go to Top of Page

ayamas
Aged Yak Warrior

552 Posts

Posted - 2009-03-26 : 08:11:16
quote:
Originally posted by sakets_2000

quote:
Originally posted by ayamas

select convert(varchar(15),'29/02/09',103)



thats not the solution.


Oops sorry.Missed on the leap year
Go to Top of Page

aakcse
Aged Yak Warrior

570 Posts

Posted - 2009-03-26 : 10:02:13
Thanks all it should be 28 and not 29 my mistake.

Regards,
aak


quote:
Originally posted by sakets_2000

quote:
Originally posted by ayamas

select convert(varchar(15),'29/02/09',103)



thats not the solution.

Go to Top of Page
   

- Advertisement -