Search code examples
iis-7asp-classic

How to get WeekDayName based on date


I am busy learning ASP. I cant find any good documentation (As good as the PHP docs).

So This is what I am trying to do:

pseudo code:

dayname = WeekDayName(daynumberfromdate(31-1-2013))

I cant find a function that can do this.


Solution

  • Use this:

    days = Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
    today = Date()
    dayNumber = DatePart("w", today)
    dayOfWeek = days(dayNumber - 1)
    

    For more information on the DatePart function see:

    DatePart Function (MSDN Library)

    You can find the full documentation for VBScript (as used by Classic ASP) here:

    http://msdn.microsoft.com/en-us/library/t0aew7h6(v=vs.84).aspx

    It's fairly comprehensive.

    Also the "Hey, Scripting Guy!" blog on Technet has a trove of old articles covering VBScript tips and tricks:

    http://blogs.technet.com/b/heyscriptingguy

    http://blogs.technet.com/b/heyscriptingguy/archive/tags/vbscript/