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
 converting string to date

Author  Topic 

gavakie
Posting Yak Master

221 Posts

Posted - 2009-10-20 : 16:17:16
I have a field that pull in a field like August 2009 ocp campaign. How can I convert that to say a date of 2009-08-31 or the end of whatever month name is in there?

X002548
Not Just a Number

15586 Posts

Posted - 2009-10-20 : 16:26:27
You need to CONVERT the varchar to a valid date

Give us more examples of different dates

You will need to have a "Rule" that says where the Date part stops

In your case it looks like the EOL delimiter is the second space for your date

You'll need to look up

CONVERT, CHARINDEX, SUBSTR

in BOL





Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page
   

- Advertisement -