HI WELCOME TO KANSIRIS

SQL Server Add Hours (Minutes) to Current Date using DateAdd Function

Leave a Comment
Add Hours to Date in SQL

To add hours to date in sql server we need to write the query like as shown below



declare @hours int;
set @hours = 5;
select  getdate() as currenttime, dateadd(HOUR, @hours, getdate()) as timeadded

When we run above query we will get output like as shown below

Output


SQL Server Add Hours to Current Date using DateAdd Function



Add Minutes to Date in SQL

To add minutes to date field we need to write the query like as shown below


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

0 comments:

Post a Comment

Note: only a member of this blog may post a comment.