web 2.0

ASP/VBScript DateAdd()

ASP/VBScript DateAdd() Returns a date to which a specified time interval has been added.

ShotDev Focus:
- Using Asp and DateAdd() function.

Syntax


DateAdd(interval, number, date)

The DateAdd function syntax has these parts:

Part Description
interval Required. String expression that is the interval you want to add. See Settings section for values.
number Required. Numeric expression that is the number of interval you want to add. The numeric expression can either be positive, for dates in the future, or negative, for dates in the past.
date Required. Variant or literal representing the date to which interval is added.
Settings

The interval argument can have the following values:

Setting Description
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

asp_dateadd.asp


<% Option Explicit %>
<html>
<head>
<title>ShotDev.Com Tutorial</title>
</head>
<body>
<%
Response.write Date()&"<br>"
Response.write DateAdd("d",10,"09/01/2010")&"<br>"
Response.write DateAdd("m",3,"09/01/2010")&"<br>"
Response.write DateAdd("n",60,"12:00")&"<br>"
Response.write DateAdd("h",3,"15:30")&"<br>"
%>
</body>
</html>

Create a asp file and save to path root-path/myasp/

Run
http://localhost/myasp/asp_dateadd.asp

Screenshot

ASP/VBScript & DateAdd()

.
.
.
Download this script.
Download

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (1 votes, average: 1.00 out of 10)
Loading ... Loading ...

Leave a Reply

You must be logged in to post a comment.