Tuesday, 29 November 2011

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:


Printer Friendly Page


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




This script displays the current month number like this: 11


Printer Friendly Page


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




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


Printer Friendly Page


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




This script displays the current year like this: 2011


Printer Friendly Page


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




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


Printer Friendly Page


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




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

http://www.aspwebpro.com/aspscripts/dates/selectpartofdate.asp

No comments:

Post a Comment