The example below demonstrates the usage of creating a web page which will display the date after adding 30 days in it from today. Suppose today's date is 29-07-03, then it will display 28-08-03 i.e. after adding 30 days in todays date. The date method is used for getting the current date and DateAdd method is used to add a time interval to any date.
Syntax for DateAdd is DateAdd(interval,number,date). In the following example, interval is "d" which states that you want to add the number (second argument) in the date field of third argument i.e. date. You could have used "m" also to add some interval in the month field of the date.
For embedding a VBScript code into your HTML page, you have to use a tag <script type= ""> to tell the HTML page that you are going to use a script now. This script type can JavaScript or VBScript and then you can use the functionalities of Javascripting or VBScripting as per your requirement. We have written the code in the body section of the HTML page.The reason for using VBScript functions in the body section is to be sure that the script is executed when the page is loading. As in the example, you can see that it will write a message on your web page at the time of loading of HTML page.
The document.write() method of VBScript is used to display something on the HTML page.
The HTML element <p> indicates the start of a paragraph block. This means that the current line of output is terminated and a blank new line is output before text display continues. If a <p> tag is encountered within a paragraph block this forces the start of a new paragraph. <b> </b> element of HTML states that the text enclosed within these tags will be displayed as bold text.
Code:
<html>
<title>Dateadd function</title>
<body>
<script type="text/vbscript">
document.write(DateAdd("d",30,date()))
</script>
<p>
This example uses <b>DateAdd</b> to calculate a date 30 days from today.
</p>
</body>
</html>
<html> </html> is the tag for starting the html file and ending it. <title> </title> tag defines what you want to be the title of your window/web-page i.e. Title bar of the web-page. The body i.e. what you want to display on your web page will come in between the <body> </body> tag.
Bookmarks