Canavar
asked on
SQL: convert string value to a datetime value.
Hi,
I need a SQL statement to convert a string to a legitimate datetime value.
String i'm entering is '30/10/2003' and i'm using the following SQL code to convert it;
Convert(datetime, @StartDate, 102) where start date is '30/10/2003'.
when i try this in query analyzer i get the error message below.
Error converting data type varchar to datetime.
help!
Ozi
I need a SQL statement to convert a string to a legitimate datetime value.
String i'm entering is '30/10/2003' and i'm using the following SQL code to convert it;
Convert(datetime, @StartDate, 102) where start date is '30/10/2003'.
when i try this in query analyzer i get the error message below.
Error converting data type varchar to datetime.
help!
Ozi
Canavar:
> String i'm entering is '30/10/2003' and i'm using the following SQL code to convert it;
> Convert(datetime, @StartDate, 102) where start date is '30/10/2003'.
102 is for when you have 'yyyy.mm.dd'.
You have 'dd/mm/yyyy', which is 103. So try this instead:
Convert(datetime, @StartDate, 103)
Hope that helps,
Dex*
> String i'm entering is '30/10/2003' and i'm using the following SQL code to convert it;
> Convert(datetime, @StartDate, 102) where start date is '30/10/2003'.
102 is for when you have 'yyyy.mm.dd'.
You have 'dd/mm/yyyy', which is 103. So try this instead:
Convert(datetime, @StartDate, 103)
Hope that helps,
Dex*
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
i sorted it mate sorry. had a bit of blackout!
ASKER
Thanks guys anyway. i just had to get away from my desk and come back with a clear mind!
Can an expert close this please?
thanks,
Canavar
Can an expert close this please?
thanks,
Canavar
>>Can an expert close this please?<<
No, but you can. See here:
What are my choices?
https://www.experts-exchange.com/help/closing.jsp#1
Anthony
No, but you can. See here:
What are my choices?
https://www.experts-exchange.com/help/closing.jsp#1
Anthony
not y.m.d which is 102