Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert date to dd/mm/yyyy hh:mm:ss format

Status
Not open for further replies.

lpatnaik

Programmer
Jul 11, 2002
53
0
0
I need to convert the date from a datetime field of a table in sql server to the format "dd/mm/yyyy hh:mm:ss". Can anyone help me out.

Regards
Lopa
 
Code:
SELECT CONVERT(varchar(10), datecol, 103) + ' ' + CONVERT(varchar(10), datecol, 108)
FROM mytable

--James
 
Hi, That is great!!!. But i need the hour in the other format. i.e. if it is 7:30 pm, it should display 07:30:00 PM and not 19:30:00 PM
Can you get around that?
Pls help its urgent
 
You could use the following query,but it doesnt really look simple.

SELECT CONVERT(VARCHAR(10),GETDATE(),103)+' '++right('0'+ltrim(SUBSTRING(CONVERT(varchar(35),getdate(),109),13,8)),8)+' '+SUBSTRING(CONVERT(varchar(35),getdate(), 109),25,3)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top