Working with dates in aSP is actually pretty straight forward, there are plenty of built in routines to help programmers accomplish the tasks at hand so lets take a look at what you need to do and build some code from there:
What do you want to do:
- Display the current date
- Formatting the date
- Getting Specific Date Details
- Getting the Name of the Month
- Getting the Name of the Weekday
To display the current date, you can insert the code:
<%=date()%>
This will result in a literal interpretation of the date. For example:
<%=date()%>
Now that we know how to get the date, we need to worry about formatting it. You can do this using a couple of built in functions to display the contents in a more friendly way.
Firstly, if you just want to format it in a more attractive manner, you can do so with the FormatDateTime command:
<%=FormatDateTime(Date(),1)%>
will result in <%=FormatDateTime(Date,1)%>
Perhaps you need something more detailed about the date than just displaying it so lets take a quick look at how to get the specific items from it.
<%=DaY(Date())%>
will display the current day such as ‘<%=DaY(Date())%>’<%=MONTH(Date())%>
will display the current MONTH such as ‘<%=MONTH(Date())%>’<%=YEaR(Date())%>
will display the current YEaR such as ‘<%=YEaR(Date())%>’
When you need to display the name of the current month, you can do so easily using the following code:
<%=Month Name(MONTH(Date()))%>
will display the current MONTH such as ‘<%=MonthName(MONTH(Date()))%>’
Getting the Name of the Week Day
Displaying the name of the exact day is also simple, just use the code below:
<%=WEEKDaYNaME(WEEKDaY(Date()))%>
will display the current MONTH such as ‘<%=WeEKDaYNaME(WEEKDaY(Date()))%>’
Last reviewed May 2, 2026.
Rate And Review This Content
Be the first to rate this. Submissions are reviewed before they appear.