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
 Transact-SQL (2000)
 varchar(10) to date in format 103

Author  Topic 

shaneschmidt
Starting Member

17 Posts

Posted - 2002-10-13 : 19:04:00
How would I convert a varchar field (10) called startdate with values of 31/12/2002 etc to a datetime in format 103 in my select statement

AjarnMark
SQL Slashing Gunting Master

3246 Posts

Posted - 2002-10-13 : 19:09:15
How about...

SELECT CONVERT(datetime, StartDate, 103)

Go to Top of Page

shaneschmidt
Starting Member

17 Posts

Posted - 2002-10-14 : 02:29:57
quote:

How about...

SELECT CONVERT(datetime, StartDate, 103)





Go to Top of Page

shaneschmidt
Starting Member

17 Posts

Posted - 2002-10-14 : 02:35:03
quote:


Many Thanks
But I still return the format 2002-09-01 00:00 etc
whan all I want to do is return the date format 01/09/2002 from the varchar(10) ie 01/09/2002
Is there another format I shoud be using to return the same value



SELECT CONVERT(datetime, StartDate, 103)





Go to Top of Page

AjarnMark
SQL Slashing Gunting Master

3246 Posts

Posted - 2002-10-14 : 16:43:49
There is no date-only data type in SQL Server. You could do

SELECT CONVERT(varchar(10), CONVERT(datetime, StartDate, 103), 103). This seems redundant to me...

Edited by - AjarnMark on 10/14/2002 16:46:16
Go to Top of Page

shaneschmidt
Starting Member

17 Posts

Posted - 2002-10-14 : 19:23:53
quote:

Thanks Mark
Im try to use a drop down menu using startdate converting
to a date in the same format ie 10/12/2002 from a
varchar and then select distinct...

There is no date-only data type in SQL Server. You could do

SELECT CONVERT(varchar(10), CONVERT(datetime, StartDate, 103), 103). This seems redundant to me...

Edited by - AjarnMark on 10/14/2002 16:46:16



Go to Top of Page
   

- Advertisement -