October 30, 2010 at 12:23 pm
I have a stored proc which accepts the parameter.
parameter is in varchar type.
e.g.
sd varchar(8) and the value enterd by user is like 20101011.
I need to change the input into 2010-10-11
October 30, 2010 at 2:16 pm
The major question is: WHY?
If you need to deal with date values, use the DATETIME instead of a varchar. It makes it a lot easier to deal with.
But to answer your original question:
SELECT STUFF(STUFF('20101011',7,0,'-'),5,0,'-')
should do it...
October 31, 2010 at 9:39 am
If you are using the parameter to insert into a datetime column, there is ABSOLUTELY no need to convert the date value.
Keep the date value in ISO YYYYMMDD date format and the insert will be unambigous.
N 56°04'39.16"
E 12°55'05.25"
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply