How to convert this datetime Thu Sep 23 19:34:06 IST 2010 to mm/dd/yyyy format

How to convert this datetime Thu Sep 23 19:34:06 IST 2010 to mm/dd/yyyy
LVL 36
Loganathan NatarajanLAMP DeveloperAsked:
Who is Participating?
 
wshark83Commented:
here's a useful link which converts dates to various formats:

http://www.sqlusa.com/bestpractices/datetimeconversion/

basically you need to use the convert(datetime,<datefield>) functions
0
 
sachitjainCommented:
set @date = CONVERT(varchar(25), @dt, 101)

where @dt is your input datetime parameter i.e. Thu Sep 23 19:34:06 IST 2010
0
 
Anthony PerkinsCommented:
How to convert this datetime Thu Sep 23 19:34:06 IST 2010 to mm/dd/yyyy format
Assuming that value is not a datetime data type (otherwise the question would never have been posed) than I suspect you need something like this:
SELECT CONVERT(varchar(10), CAST(SUBSTRING(@YourDate, 5, 6) + ',' + RIGHT(@YourDate, 4) AS date), 101)
0
 
Loganathan NatarajanLAMP DeveloperAuthor Commented:
thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.