VBScript DateSerial Function



It is a function that returns a date for the specified day, month and year parameters.

Syntax

DateSerial(year,month,day)

Parameter Description

  • year, a Required Parameter. A number between 100 and 9999 or a numeric expression. Values between 0 and 99 are interpreted as the years 1900 to 1999. For all other year arguments, use a complete four-digit year.

  • month, a Required Parameter. It can also be in the form of an expression, which should range from 1 to 12.

  • day, a Required Parameter. It can also be in the form of an expression, which should range from 1 to 31.

Example

<!DOCTYPE html>
<html>
   <body>
      <script language = "vbscript" type = "text/vbscript">
         document.write(DateSerial(2013,5,10))
       
      </script>
   </body>
</html>

When you save it as .html and execute it in Internet Explorer, then the above script will produce the following result −

Fri May 10 00:00:00 UTC+0530 2013 
vbscript_date.htm
Advertisements