Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

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

Jun 6, 2015
Introduction:

Here I will explain how to add hours to current date using DateAdd function in
sql server with example or adding hours or minutes to date in sql server. By using DateAdd function in sql server we can add hours or minutes to current date in sql server.
Description:

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

If you want to get date in different formats like dd/mm/yyyy or dd-mm-yyyy or etc… check this article Change SQL Get only date from datetime in different formats

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

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

Output


SQL Server Add Minutes to Current Date using DateAdd Function

I hope it helps you…. 

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email

1 comments :

Anonymous said...

Hi Suresh,

I need Query as Day wise date function. Please help.

Give your Valuable Comments

Other Related Posts

© 2015 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.