Click here to Skip to main content
15,888,579 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi
I have table,in that i declare one column name as DateSend as nvarchar(10) and i store time as
10.12.11
15.45.44
17.00.00

form above i need to convert to 12 hr like

10:12:11 AM
03:45:44 PM
05:00:00 PM

what is the sql query ?


Regards

Aravind
Posted
Comments
Duncan Edwards Jones 12-Sep-14 4:01am    
Why are you storing a date in an NVarchar column - why not use the appropriate data type?
Aravindba 12-Sep-14 5:04am    
yes,actually this is existing one,in most of the place need to show like 15.33.13,so we declare as nvarchar.But in report i need to show 12hr format time like 03:33 or 03:33 PM
Thanks7872 12-Sep-14 4:45am    
Use reply button while commenting to any member's comment.
Thanks7872 12-Sep-14 4:46am    
If in most of the places you need some specific format,than you should handle it on code side.
Aravindba 12-Sep-14 5:04am    
thank u for ur reply,in most of plac i dont want any format,just what i save in sql ,that only need to show like 15.33.13,in report one column i need to show as 12hr format.

1 solution

assuming ur table name as table1 and column as DateSend of datatype nvarchar(10)

try this

SQL
select REPLACE(CONVERT(varchar(20),CAST(REPLACE(DateSend ,'.',':') AS TIME),109),'.0000000',' ') FROM table1


good luck ;-)
 
Share this answer
 
Comments
Aravindba 12-Sep-14 5:59am    
Thanx a lot,it work,thanx bro
george4986 12-Sep-14 6:08am    
u are always welcome ;-)

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