Click here to Skip to main content
15,893,668 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to get 12 hours format time from getdate function in sql server.

Thanks,
-RG
Posted
Comments
Sergejack 4-Apr-14 6:24am    
Dealing with presentation is not what you should SQL Server for.

See the CONVERT[^] function.
 
Share this answer
 
Comments
OriginalGriff 4-Apr-14 6:24am    
Down vote countered
CPallini 4-Apr-14 8:03am    
Thak you, Sir. Now I'm gonna emulate you.
To get just the time:
SQL
SELECT CONVERT(TIME, GETDATE())

For a specific format time, you need to convert it to a string:
SQL
SELECT RIGHT(CONVERT(VARCHAR,GETDATE(),100),7)
 
Share this answer
 
My self solved it by below script

select CONVERT(varchar(20), CONVERT(TIME(0),CONVERT(VARCHAR,GETDATE(),8)),0)


Thanks,
-RG
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900