A handy post to help refresh the various date/time functions and formats available for ASP developers.
Function | Output | |
---|---|---|
The date today is: | Date | 15/08/2007 |
The time now is: | Time | 16:32:21 |
The date and time is: | Now | 15/08/2007 16:32:21 |
The name of the day today is: | WeekdayName(Weekday(Date)) | Wednesday |
The abbreviated day name is: | WeekdayName(Weekday(Date),True) | Wed |
The date is: | Day(Date) | 15 |
The name of the month is: | MonthName(Month(Date)) | August |
The abbreviated month name is: | MonthName(Month(Date),true) | Aug |
The month is: | Month(Date) | 8 |
The year is: | Year(Date) | 2007 |
The date 7 days ago was: | DateAdd(“d”,-7,Date) | 08/08/2007 |
The FormatDateTime function formats and returns a valid date or time expression
FormatDateTime(date,format)
Parameter | Description |
---|---|
date | Required. Any valid date expression (like Date() or Now()) |
format | Optional. A Format value that specifies the date/time format to use |
Format Values
Format | Description |
---|---|
0 | Display a date in format mm/dd/yy. If the date parameter is Now(), it will also return the time, after the date |
1 | Display a date using the long date format: weekday, month day, year |
2 | Display a date using the short date format: like the default (mm/dd/yy) |
3 | Display a time using the time format: hh:mm:ss PM/AM |
4 | Display a time using the 24-hour format: hh:mm |