DateAdd Function

Tips >>ASP Functions

WANTS TO MAKE SOFTWARE WITHOUT KNOWLEDGE OF PROGRAMMING? CLICK HERE 

The DateAdd function returns a date to which a specified time interval has been added. The DateAdd () functions allows us to add or subtract from a date or time. Date Add returns a date or time that has been modified by the number parameter. The DateAdd function lets you add a certain amount of time to any date. You can determine what will be a week from now, what was 3 days ago, or any other difference. The DateAdd function adds a time interval to any date.


The Syntax of DateAdd function is :-

DateAdd(interval,number,date)

Its Description is :-

Parameter Description
Interval

Required. The interval you want to add .
Can take the following values :-

  • yyyy - Year
  • q - Quarter
  • m - Month
  • y - Day of year
  • d - Day
  • w - Weekday
  • ww - Week of year
  • h - Hour
  • n - Minute
  • s - Second

Example#1 :-

Code :-
'Add one month to January 31, 2000
document.write(DateAdd("m",1,"31-Jan-00"))
Output :-
2/29/2000

Example#2 :-

Code :-
'Add one month to January 31, 2001
document.write(DateAdd("m",1,"31-Jan-01"))
Output :-
2/28/2001

Example#3 :-

Code :-
'Subtract one month from January 31, 2001
document.write(DateAdd("m",-1,"31-Jan-01"))
Output :-
12/31/2000

Example#4 :-

Code :-
<% =Date %>
<% =DateAdd("WW", 6, Date) %>
Output :-
3/16/99
4/27/99

Example#5 :-

Code :-
<% =Now %>
<% =DateAdd("S", 30, Now) %>
Output :-
3/16/99 12:14:00 PM
3/16/99 12:14:30 PM

Example#6 :-

Code :-
<% ="1/1/2001" %>
<% =DateAdd("YYYY", 1000, "1/1/2001") %>
Output :-

1/1/2001
1/1/3001

 

 
E-mail : sales@virtualsplat.com
Phone : +91-9892413501

Whatsapp Icon +91-9967648641

Whatsapp Icon +91-9967648641