views:

52

answers:

3

I have datetime value as

  1. 2010-04-07 09:00:00.000

  2. 2010-04-07 14:30:00.000

how to convert the 14:30 to 2:30 pm

A: 

Do you want to do it in a query if so look.

select date_format(date, "%Y-%m-%d %r") from table_name

also look at this

FOR MSSQL YOU SHOULD USE convert() method

Salil
Thanks for yr reply..but im using MSSQL. so there is no date_format command as recognizable one
Ranjana
use convert method for MSSQL likn is given in an answer.
Salil
+1  A: 
SELECT RIGHT(CONVERT(varchar(7), Myvalue, 100), 7)

Even better would be to do this in the client code...

gbn
A: 

gbn, didn't you mean SELECT RIGHT(CONVERT(varchar(AT-LEAST-19), Myvalue, 100), 7) ?

Rad