0

I want to change the DateTime from looking like "2012-05-02 24:12:23.000" to just display the hour and minute like "12:00".

The data is automatically put in the SQL table from a UDP message then the webpage loads the data into a grid.

Dmdtrain
  • 13
  • 3

1 Answers1

0

in sql server :

SELECT CONVERT(VARCHAR(5),getdate(),108) 

in postgresql:

select to_char(now() , 'hh:mi')
eshirvana
  • 23,227
  • 3
  • 22
  • 38
  • This is not the best way to solve this problem. For instance, what if your program needs to support multiple cultures? Since you have turned a date into a string, you lose the ability to accurately sort on it or to format it for other cultures. The comment by Timothy G is the correct way to solve this problem. – Dave Holden May 13 '21 at 18:58