Engage Share or leave a rating Copy, send, or respond when you finish

Leave A Rating

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:

  1. Display the current date
  2. Formatting the date
  3. Getting Specific Date Details
  4. Getting the Name of the Month
  5. Getting the Name of the Weekday

Display The Current Date

To display the current date, you can insert the code:

    <%=date()%>

This will result in a literal interpretation of the date. For example:

    <%=date()%>


Formatting The 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)%>


Getting Specific Date Details

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())%>’


Getting the Name of the Month

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.