|
![]() New-->Using DatePart and other Date Functions New-->Understanding Includes (Updated) Using Single & DoubleQuotes in ASP with SQL Statements (Updated) Emailing Form Results Mass Emailing with CDO Using The Ad Rotator ASCII Character Set 0-127 Using Date & DatePart, and Others There are different intervals you can use when you use DatePart (listed at bottom of page), along with several constants (which I won't get into on this page). DatePart returns part of a specified date in this form: DatePart(interval, date[, firstdayofweek[, firstweekofyear]])List of Arguments interval Required. String expression that is the interval of time you want to return. See Settings section for values. date Required. Date expression you want to evaluate. firstdayof week Optional. Constant that specifies the day of the week. If not specified, Sunday is assumed. See Settings section for values. firstweekofyear Optional. Constant that specifies the first week of the year. If not specified, the first week is assumed to be the week in which January 1 occurs. See Settings section at the bottom of the page for useable values. Below are examples of some different ways to use DatePart, along with other popular date-type functions. Below each example is the code which creates it.
Here is today's date (using Date) : 9/9/2010 The month's name is September
Number of the month : 9
Here is the abbreviated month : Sep
The year is : 2010
Today's date is :9
Here is the Day of the week : 5
Here is the Week of the Year : 37
The day of the year is : 252 (Which means that here are 113 Days Left this year)
Intervals and Constants for DatePart
The firstdayofweek argument can have any the following values:
|