Link to home
Start Free TrialLog in
Avatar of amukta
amukta

asked on

Date conversion from mm/dd/yyyy to yyyymmdd in sqlserver 2005

Hi!
I need convert date in the format mm/dd/yyyy to yyyymmdd
and also mm/dd/yy  to yyyymmdd format.I'm not able to find an appropriate solution for that.
Also how do I convert time in the format hh:mm:ss.xxx(xxx represent milli seconds)
to hh:mm:ss:xxxx .
How do I convert time in the format hhmmssx to hh:mm:ss:xxx?
How do I convert time in the format hh:mm:ss.xxx to hh:mm:ss?
How do I convert time in the format hh:mm:ss to hhmmss?
All of these in sql server 2005.
can I get the code if possible?
Please let me know ASAP.

Thanks in advance


Avatar of Doc_McAlister
Doc_McAlister

You actually want to change what they are **stored as** or how they are formatted when you select them?
Avatar of Anthony Perkins
Datetime and smalldatetime are not stored in any regional format.  In order to convert for display purposes to some typical formats, take a look at the CONVERT() function in BOL
Use the Convert function in SQL to convert the date format according to your choice.
You can specify the <Style> tag according to your choice.
For eg:- convert (datetime, <Column Name>, 112 ) will give you the format yyyymmdd
Like wise you can get different formats.
Avatar of amukta

ASKER

Hi! Doc McAlister,

I want to change the formatwhile selecting them.
Thanks,
Amukta
Avatar of amukta

ASKER

Hi! ursangel,

Unable to do it with the solutio u've sent me, for soem reason.
Is there any other alternative.

Thanks,
>>Unable to do it with the solutio u've sent me, for soem reason.<<
Try posting your query and we can be more specific.

>>Is there any other alternative.<<
There is no other alternative with T-SQL.
ASKER CERTIFIED SOLUTION
Avatar of Doc_McAlister
Doc_McAlister

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial