Click here to Skip to main content
15,893,904 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I use the datetime in table, but in my procedure I use varchar.

I convert varchar to datetime like...
SQL
CONVERT(DATETIME, 2013/02/20,103)
.
This is not giving problem on my server, but on other server query gives problem.

Please find solution.
Posted
v2
Comments
phil.o 22-Mar-13 3:40am    
"I use the datetime in table, but in my procedure I use varchar."

Why ?

Hi Try this...

SQL
SET DATEFORMAT dmy
SELECT '22/02/2013'

SET DATEFORMAT mdy
SELECT '03/22/2013'

SET DATEFORMAT ymd
SELECT '2013/03/22'

-- Detault format is "mdy"


Check the following link...

SET DATEFORMAT (Transact-SQL)[^]
Regards
GVPrabu
 
Share this answer
 
v2
Try this:
SQL
CONVERT(DATETIME, '2013/02/20',103)

or
SQL
DECLARE @myDate VARCHAR(10)

SET @myDate = '2013/03/20'
CONVERT(DATETIME, @myDate,103)


Do you see the difference?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900