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 |
Steve2106
Posting Yak Master
183 Posts |
Posted - 2011-03-21 : 16:32:25
|
Hi There,After your help again;I have a stored procedure that gets it's variables from a webform.On the webform there is a datepicker that passes the date chosen to the stored procedure. If the date is passed as 14/03/2011 I need it to be converted to 2011-03-14 so I can use it in the WHERE clause like this: dbo.SearchedActions.DateRaised >= '2011-03-14'.How would I convert the passed in date to the format above.Thanks for your help.Best Regards,Steve.Steve |
|
rkruis
Starting Member
28 Posts |
Posted - 2011-03-21 : 16:44:33
|
CONVERT(varchar,'14/03/2011',103)Try that! |
 |
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
jeffw8713
Aged Yak Warrior
819 Posts |
Posted - 2011-03-21 : 21:37:29
|
In addition to the other questions:What is the data type of the parameter you are passing in? It should be a datetime data type - that way you don't have anything to convert.And finally, how are you constructing the command object to execute the procedure? If you are concatenating a string and executing it, you need to review SQL injection and change your approach. You should be using defined parameters and setting the data type for the parameter, then assigning it the value. Using this approach, you don't need to worry about translating from one format to another - it will happen automatically.Jeff |
 |
|
|
|
|