0

我想知道WeekdayNow. 我到处搜索,但找不到任何东西。

我认为我必须以某种方式将DateDiff-function 与 -function 一起使用WeekDay

场景是:

我有varWeekDay一周中的一天的变量,例如:1 / 2 / 3 / 4 / 5 / 6 / 7

还有一个varStartTime带有一天中时间的变量:hh:mm

最后一个变量varStopTime也带有一天中的时间:hh:mm

if varWeekday = Weekday(now, 2) and varStartTime < formatdatetime(now, 4) then
  .... Write how long time till start in hours / minutes
elseif varWeekday = Weekday(now, 2) and varStartTime >= formatdatetime(now, 4) and varStopTime < formatdatetime(now, 4) then
  response.write("Already started!")
else
  .... Write how long time till start in days / hours / minutes
end if

“多长时间”可以是:“从现在起 2 天 3 小时 27 分钟”

应从特定日期时间生成相同的输出。例如:06/08/2012 23:55 是“从现在开始 1 天 13 分钟”

我真的希望你们能帮忙!:)

4

1 回答 1

1

我不完全了解您需要的开始时间和结束时间,但是此脚本会告诉您从现在到一周中特定日期的开始之间有多少时间。

<%
Dim varNow : varNow = Now()
Dim varWeekday : varWeekday = 7 'This is the weekday to look for (1 is Sunday, 7 is Saturday)

'This next line sets the time to the start of the day
Dim varThisDate : varThisDate = DateSerial(Year(varNow), Month(varNow), Day(varNow))
Dim varThisWeekday
Do
    varThisDate = DateAdd("d", 1, varThisDate)
    varThisWeekday = Weekday(varThisDate)
    If varThisWeekday = varWeekday Then
        Exit Do
    End If
Loop

'These next lines just convert and display the remaining time into the different units
Response.Write("Until next " & WeekdayName(varWeekday) & "<br />")

Dim varSeconds : varSeconds = DateDiff("s", varNow, varThisDate)
Dim varDays : varDays = Int(varSeconds / 60 / 60 / 24)
varSeconds = varSeconds - (varDays * 24 * 60 * 60)
Dim varHours : varHours = Int(varSeconds / 60 / 60)
varSeconds = varSeconds - (varHours * 60 * 60)
Dim varMinutes : varMinutes = Int(varSeconds / 60)
varSeconds = varSeconds - (varMinutes * 60)

Response.Write("Days: " & varDays & "<br />")
Response.Write("Hours: " & varHours & "<br />")
Response.Write("Minutes: " & varMinutes & "<br />")
Response.Write("Seconds: " & varSeconds & "<br />")
%>
于 2012-08-06T05:05:09.750 回答