Date with HH:MM appended ?

HI,

How do i get the mentioned format. if today is 7th July then,

2015-07-07 15:30

i.e. date with HH and MM appended in today's date ?

want just one simple statement. don't want to write big query as i want to use this condition in one of the joining criteria.

Regards

July 7th, 2015 1:57am

Hello - You can use this:

SELECT REPLACE( CONVERT ( VARCHAR, GetDate(), 102), '.', '-') + ' ' + CONVERT ( VARCHAR, GetDate(), 108)

Hope this helps !

Free Windows Admin Tool Kit Click here and download it now
July 7th, 2015 2:01am

almost right but i want only till minute.

your exp. is giving "seconds" as well. 

output is : 2015-07-07 13:03:42

while i want is : 2015-07-07 13:03

(with seconds eliminated)

regards

July 7th, 2015 2:06am

Hello - You can try this:

SELECT REPLACE( CONVERT ( VARCHAR, GetDate(), 102), '.', '-') + ' ' + 
LEFT ( CONVERT ( VARCHAR, GetDate(), 108), 5 )

Hope this helps !

Free Windows Admin Tool Kit Click here and download it now
July 7th, 2015 2:09am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics