Click here to Skip to main content
15,886,137 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How i get difference of 20 mints in getdate and database column date but my server is in uk and my country time and uk server time is different. difference of my country time and server time is 2 hour

What I have tried:

SQL
select @currentdate=getDate();

Select LastAccess from session where CAST(lastAccess As Date)=Cast(@currentdate As Date)

select @different_MINT=datediff(mint,currentdate,LastAccess )

if @different_MINT > 20
Begin
// Update Query
END
Posted
Updated 8-Mar-16 20:47pm
v2
Comments

1 solution

Try this:
SQL
DECLARE @datetoChange AS DATETIME
SELECT @datetoChange = '2009-01-01 12:00:00.000'

SELECT @datetoChange, 
	DATEDIFF(hh,GETUTCDATE(), GETDATE()) AS DIFFfromUTC, 
	DATEADD(hh,DATEDIFF(hh,GETUTCDATE(), GETDATE()),@datetoChange) AS modifiedDate


Source: SQL SERVER UTC date to local time zone[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900