Click here to Skip to main content
15,936,565 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want the date format for a date..The format should be like hh:mm:ss AM/PM
Please help me to find it.
Posted

Check this

SQL
DECLARE @MyDate datetime
SET @MyDate = Getdate()
SELECT
CASE WHEN DATEPART(HOUR,@MyDate) >12 then Convert(VARCHAR(28), Cast(@MyDate AS DATETIME), 8) +' PM'
ELSE
Convert(VARCHAR(28), Cast(@MyDate AS DATETIME), 8) +' AM'
END
 
Share this answer
 
v2
Go with below link ....
[Date time Format ]

Regards,
Vijay
 
Share this answer
 
Comments
Member 9492907 8-Jan-13 0:50am    
i already go through that link..but i didn't find it..
Santhosh Kumar Jayaraman 8-Jan-13 1:05am    
check solution 3
I think the best date format in sqlserver is DateTime which has both date and time altogether
 
Share this answer
 
Comments
Member 9492907 8-Jan-13 0:48am    
I d't need the type....i want the format like HH:MM:SS AM/PM

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