Select Part of Date ASP Script - ASP Web Pro
  Active Server Pages Programming by ASP Web Pro

ASP Scripts

SELECT PART OF DATE

It is often useful to be able to select and display only a specific portion of the date. Here are a few examples that you can use with ASP / VBScript:

<HTML>
<HEAD><TITLE>Printer Friendly Page</TITLE></HEAD>
<BODY>

<% Response.Write DatePart("m", Date()) %>

</BODY>
</HTML>

This script displays the current month number like this: 7

<HTML>
<HEAD><TITLE>Printer Friendly Page</TITLE></HEAD>
<BODY>

<% Response.Write DatePart("d", Date()) %>

</BODY>
</HTML>

This script displays the current date for the month like this: 6

<HTML>
<HEAD><TITLE>Printer Friendly Page</TITLE></HEAD>
<BODY>

<% Response.Write DatePart("yyyy", Date()) %>

</BODY>
</HTML>

This script displays the current year like this: 2008

<HTML>
<HEAD><TITLE>Printer Friendly Page</TITLE></HEAD>
<BODY>

<% Response.Write DatePart("ww", Date()) %>

</BODY>
</HTML>

This script displays the current week of the year like this: 28

<HTML>
<HEAD><TITLE>Printer Friendly Page</TITLE></HEAD>
<BODY>

<% Response.Write DatePart("q", Date()) %>

</BODY>
</HTML>

This script displays the current quarter of the year like this: 3

< Back to ASP Scripts


 

 

Main Menu
Home
ASP Scripts
ASP Tutorials
JavaScripts
Awards
Contact Us

Email This Page

Other Resources
ASP Web Hosting
Search Engine Submission
Programming Help

 

 

 

Other ASP Web Sites

Site Map

 

Last Updated:
06 July 2008