VBScript: More Fun with the Date Functions - Parsing out the Month, Day, and Year from the Current Date: (Page 2 of 6 )
<html>
<body>
<script type="text/vbscript">
document.write("Today's date is: ") & Date & "<br /><br />"
document.write("This is month number ") & (DatePart("m",Date))
document.write("<br />This is day number ") & (DatePart("d",Date))
document.write("<br />The year is ") & (DatePart("yyyy",Date))
</script>
</body>
</html>
This code results in the text:
Today's date is: 11/28/2007
This is month number 11
This is day number 28
The year is 2007
Parsing out the Month, Day, and Year from a Specified Date:
<html>
<body>
<script type="text/vbscript">
document.write("My next birthday is 04/22/2007") & "<br /><br />"
document.write("This is month number ") & (DatePart("m","04/22/2007"))
document.write("<br />This is day number ") & (DatePart("d","04/22/2007"))
document.write("<br />The year is ") & (DatePart("yyyy","04/22/2007"))
</script>
</body>
</html>
As you can see, the only difference is the replacement of the Date function with our specified date.
Next: Serial Dating >>
More BrainDump Articles
More By James Payne