ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old April 27th, 2008, 08:49 PM
neverends neverends is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 81 neverends User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 h 51 m 35 sec
Reputation Power: 5
Comparing Time

I have a problem comparing times. I'm not sure why it won't work. I am pulling the data from an SQL database.

I know that MyTime = 1/1/1900 11:00:00 AM
GetNADs("TimeStart")) = 1/1/1900 10:30:00 AM
GetNADs("TimeEnd")) = 1/1/1900 12:00:00 PM

It has some kind of problem with the second part of the check.


Here's what I've tried:

Code:
If (MyTime1 > GetNADs("TimeStart")) AND (MyTime1 < GetNADs("TimeEnd")) Then

     GameDayProblem5 = 1

Else
     GameDayProblem5 = 0

End If

Reply With Quote
  #2  
Old April 27th, 2008, 11:22 PM
alexk13's Avatar
alexk13 alexk13 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Location: Sydney, Australia
Posts: 50 alexk13 User rank is Corporal (100 - 500 Reputation Level)alexk13 User rank is Corporal (100 - 500 Reputation Level)alexk13 User rank is Corporal (100 - 500 Reputation Level)alexk13 User rank is Corporal (100 - 500 Reputation Level) 
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
  1. <%
  2. Function datetimeToStr(thisDateTime)
  3.     thisDateTimeYr = datePart("yyyy", thisDateTime) * 10000000000
  4.     thisDateTimeMt = datePart("m", thisDateTime) * 100000000
  5.     thisDateTimeDy = datePart("d", thisDateTime) * 1000000
  6.     thisDateTimeHr = datePart("h", thisDateTime) * 10000
  7.     thisDateTimeMn = datePart("n", thisDateTime) * 100
  8.     thisDateTimeSc = datePart("s", thisDateTime) * 1
  9.     thisDateTimeStr = thisDateTimeYr + thisDateTimeMt + thisDateTimeDy + thisDateTimeHr + thisDateTimeMn + thisDateTimeSc
  10.     datetimeToStr = thisDateTimeStr
  11. End Function
  12. %>

To use this function in your case, you can use this code as a good starting point:
ASP Code:
Original - ASP Code
  1. <%
  2. 'Create 3 DateTimes - these can be pulled from DB Fields
  3. time1 = dateSerial(1900, 1, 1) & " " & timeSerial(11, 00, 00)
  4. time2 = dateSerial(1900, 1, 1) & " " & timeSerial(10, 30, 00)
  5. time3 = dateSerial(1900, 1, 1) & " " & timeSerial(12, 00, 00)
  6.  
  7. 'Write the dateTimes to the screen for debuggin purposes
  8. Response.Write time1 & "<br />" & time2 & "<br />" & time3 & "<br />"
  9.  
  10. 'Convert to custom Date Time String
  11. MyTime = datetimeToStr(time1)
  12. TimeStart = datetimeToStr(time2)
  13. TimeEnd = datetimeToStr(time3)
  14.  
  15. 'Do Comparison
  16. If (MyTime > TimeStart) AND (MyTime < TimeEnd) Then
  17.      GameDayProblem5 = 1
  18. Else
  19.      GameDayProblem5 = 0
  20. End If
  21. Response.Write GameDayProblem5
  22. %>

Hope this helps

Last edited by alexk13 : April 27th, 2008 at 11:24 PM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Comparing Time


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway