ASP Classic - Get last weeks date by day number

瘦欲@ 提交于 2019-12-13 08:37:09

问题


For example: What was the Date (format: MM/DD/YYYY) for 1? and the answer would be: 6/30/2014

Day number works like this:

Monday=1
...
Friday=5
Sunday=7

So something like this:

<%
   dim GetPastDay
   GetPastDay=1  
  '^ ^ ^ THIS WOULD MEAN THAT WE ARE LOOKING TO GET PAST/LAST MONDAYS DATE 
  ' AND IF WE WHERE TO REPLACE THE 1 WITH A 5 THEN IT WOULD MEAN PAST/LAST FRIDAY.

   dim GetPastDate
   '** S.O.S. -> I'M STUCK HERE! <- **
%>

THE FINAL OUTPUT WOULD BE:

<%
   Response.write "Last Date for day: " & GetPastDay & " was Date: " & GetPastDate
%>

回答1:


' Test each possible entry from Monday (1) to Sunday (7)...
For i = 1 To 7

    ' Calculate the number of days to subtract from today's date...
    j = (8 - i) Mod 7 + 1

    ' Get the date...
    d = Date - j

    ' Display the date and the weekday...
    MsgBox "Date: " & d & vbCrLf & "Day: " & WeekDayName(WeekDay(d))

Next


来源:https://stackoverflow.com/questions/24520148/asp-classic-get-last-weeks-date-by-day-number

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!