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 2000 Forums
 SQL Server Development (2000)
 Converting varchar to datetime

Author  Topic 

Bobba Buoy
Starting Member

36 Posts

Posted - 2003-06-17 : 06:21:37
I am using sql server 2000 and I have a field that is varchar that contains nothing but dates in the format 'June 16' for instance. Can I convert that to datetime or shortdatetime without loss of data?

Thanks!

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2003-06-17 : 07:16:58
You'll need to tack on a year, but aside from that it shouldn't be a problem.

declare @t varchar(10)
set @t = 'June 16'
select convert(datetime,@t+' 2003')

 


Jay White
{0}
Go to Top of Page
   

- Advertisement -