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.
| Author |
Topic |
|
Goalie35
Yak Posting Veteran
81 Posts |
Posted - 2005-10-20 : 14:39:17
|
| I have a varchar date in my stored procedure that comes in as "mm/yyyy" but I need to convert it to a datetime of "mm/dd/yyyy" with "dd" being the 1st of the month before I place it into the database.So for example, I bring in "10/2005" as a varchar and need to convert it to a datetime of "10/1/2005"Is there a sql conversion that can do this?Thanks in advance.-Goalie35 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
Kristen
Test
22859 Posts |
Posted - 2005-10-20 : 14:54:46
|
| SET DATEFORMAT DMYDECLARE @d varchar(7)SELECT @d = '10/2005'SELECT CONVERT(datetime, '01/' + @d)Kristen |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-10-21 : 01:30:38
|
| >>I have a varchar date in my stored procedure that comes in as "mm/yyyy"Hereafter use proper DateTime datatype and pass VALID date to avoid unnecessary conversionsMadhivananFailing to plan is Planning to fail |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2005-10-21 : 09:33:38
|
quote: Originally posted by Kristen SET DATEFORMAT DMYDECLARE @d varchar(7)SELECT @d = '10/2005'SELECT CONVERT(datetime, '01/' + @d)Kristen
I hate messing with settings.....how can you tell what the current setting for dateformat is? Database propoerties?Brett8-)Hint: Want your questions answered fast? Follow the direction in this linkhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-10-21 : 10:23:21
|
| >>how can you tell what the current setting for dateformat is? Database propoerties?DBCC USEROPTIONSMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|