I am currently using

SELECT FORMAT (getdate(), 'MM/dd/yyyy, hh:mm:ss tt') as date

The output is in the format I need, but is off by 6 hours.

05/30/2019, 06:26:01 PM

I just need to add 6 hours to it. been using dateadd, but I keep loosing the format I need it to be on.

SELECT DATEADD(Hours,6,GETDATE()) outputs in wrong format

  • So, why don't you combine the two?: SELECT FORMAT(DATEADD(Hours,6,GETDATE()), 'MM/dd/yyyy, hh:mm:ss tt') AS date ; – ypercubeᵀᴹ May 30 '19 at 16:35
  • Or change the server to the desired timezone... – Jonathan Fite May 30 '19 at 17:03
  • Thanks, I figured that is what I needed to do. just cant do it right, thanks – lviz May 31 '19 at 9:51

You need to call the DATEADD function inside the FORMAT function:

SELECT FORMAT( DATEADD(HOUR, 6, GETDATE()), 'MM/dd/yyyy, hh:mm:ss tt') as date
| improve this answer | |
Declare @dt datetime ;
select @dt=  DATEADD(Hour,6,GETDATE())
SELECT FORMAT (@dt, 'MM/dd/yyyy, hh:mm:ss tt') as date
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.