July 19, 2019 at 7:13 pm
Hi,
I'm in need of a formula that would account for next day change. I am working on a view that adds 2 hours (due to changing time zone) to the "create date". However, if adding the 2 hours to the create date falls into the next day, the DATE does NOT change. How can I account for that? Im using
dateadd(hh,2)
to add the date, but I'm not sure how to account for the next date if the time falls into that.
July 19, 2019 at 9:16 pm
The date does change or am I missing something?
DECLARE @Date DATETIME = '2019-07-19 22:42:45.880'
SELECT DATEADD(hh, 2, @Date)
Result:
2019-07-20 00:42:45.880
--Vadim R.
July 20, 2019 at 7:27 pm
Hi, I'm in need of a formula that would account for next day change. I am working on a view that adds 2 hours (due to changing time zone) to the "create date". However, if adding the 2 hours to the create date falls into the next day, the DATE does NOT change. How can I account for that? Im using
dateadd(hh,2)to add the date, but I'm not sure how to account for the next date if the time falls into that.
One thing that I can say for certain is that the DATEADD function takes 3, not 2, parameters. See the post that rVadim posted on this thread.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply