
April 27th, 2008, 11:22 PM
|
 |
Contributing User
|
|
Join Date: Nov 2004
Location: Sydney, Australia
Posts: 50
  
Time spent in forums: 6 Days 4 h 2 m 49 sec
Reputation Power: 6
|
|
I've always had problems with date/time calculations, so I came up with this little function:
ASP Code:
Original
- ASP Code |
|
|
|
<% Function datetimeToStr(thisDateTime) thisDateTimeYr = datePart("yyyy", thisDateTime) * 10000000000 thisDateTimeMt = datePart("m", thisDateTime) * 100000000 thisDateTimeDy = datePart("d", thisDateTime) * 1000000 thisDateTimeHr = datePart("h", thisDateTime) * 10000 thisDateTimeMn = datePart("n", thisDateTime) * 100 thisDateTimeSc = datePart("s", thisDateTime) * 1 thisDateTimeStr = thisDateTimeYr + thisDateTimeMt + thisDateTimeDy + thisDateTimeHr + thisDateTimeMn + thisDateTimeSc datetimeToStr = thisDateTimeStr End Function %>
To use this function in your case, you can use this code as a good starting point:
ASP Code:
Original
- ASP Code |
|
|
|
<% 'Create 3 DateTimes - these can be pulled from DB Fields time1 = dateSerial(1900, 1, 1) & " " & timeSerial(11, 00, 00) time2 = dateSerial(1900, 1, 1) & " " & timeSerial(10, 30, 00) time3 = dateSerial(1900, 1, 1) & " " & timeSerial(12, 00, 00) 'Write the dateTimes to the screen for debuggin purposes Response.Write time1 & "<br />" & time2 & "<br />" & time3 & "<br />" 'Convert to custom Date Time String MyTime = datetimeToStr(time1) TimeStart = datetimeToStr(time2) TimeEnd = datetimeToStr(time3) 'Do Comparison If (MyTime > TimeStart) AND (MyTime < TimeEnd) Then GameDayProblem5 = 1 Else GameDayProblem5 = 0 End If Response.Write GameDayProblem5 %>
Hope this helps
Last edited by alexk13 : April 27th, 2008 at 11:24 PM.
|