User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP section within the Web Development category of DaniWeb, a massive community of 391,618 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,699 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP advertiser: Lunarpages ASP Web Hosting
Views: 1435 | Replies: 3 | Solved
Reply
Join Date: Jan 2007
Posts: 10
Reputation: nekesa is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
nekesa nekesa is offline Offline
Newbie Poster

Troubleshooting Strange behavior with Date() function

  #1  
Jan 30th, 2007
I'm using this code to place Time\Date stamps in specific Access Columns:
  1. Dim conn,strsql,sql_update,ssn,cps,hdDate,TOD,PageDate,h
  2. h=hour(now())
  3.  
  4. ssn = "Select SSN From CWCT07 where SSN = '" & Request.Form("SSN") & "'"
  5.  
  6. If _
  7. (Request.form("PageDate")) = "1/30/2007" And "h" < "12" _
  8. Then _
  9. sql_update = "Update CWCT07 Set Jan30AM = '" & Request.Form("hdDate") & "' where ssn = '" & Request.form("ssn") & "'" _
  10. Else If _
  11. (Request.form("PageDate")) = "1/30/2007" And "h" > "12" _
  12. Then _
  13. sql_update = "Update CWCT07 Set Jan30PM = '" & Request.Form("hdDate") & "' where ssn = '" & Request.form("ssn") & "'" _
  14. Else If _
  15. (Request.form("PageDate")) = "2/05/2007" And "h" < "12" _
  16. Then _
  17. sql_update = "Update CWCT07 Set Feb02AM = '" & Request.Form("hdDate") & "' where ssn = '" & Request.form("ssn") & "'" _
  18. Else _
  19. response.write(DATE()) _
  20. End If

I get the correct answer:
1/30/2007 7:49:19 AM
But it is going into the Jan30PM column, not the Jan30AM Column. Shouldn't it be reading 7 as less than 12? Is there anyway to parse for the AM/PM part of the Date Function??

Thanks
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2005
Location: Dallas, TX
Posts: 481
Reputation: campkev is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 19
campkev campkev is offline Offline
Posting Pro in Training

Re: Strange behavior with Date() function

  #2  
Jan 30th, 2007
problem is not with the date function.

you are comparing the string "h" to the string "12"
"h" < "12" is always going to return false

you need to compare your variable h to the number 12

h < 12
Reply With Quote  
Join Date: Jan 2007
Posts: 10
Reputation: nekesa is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
nekesa nekesa is offline Offline
Newbie Poster

Re: Strange behavior with Date() function

  #3  
Jan 30th, 2007
Thanks. That works.

Now I just need to make sure the time is a 24 hour clock....not AM/PM?




Originally Posted by campkev View Post
problem is not with the date function.

you are comparing the string "h" to the string "12"
"h" < "12" is always going to return false

you need to compare your variable h to the number 12

h < 12
Reply With Quote  
Join Date: Jul 2005
Location: Dallas, TX
Posts: 481
Reputation: campkev is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 19
campkev campkev is offline Offline
Posting Pro in Training

Re: Strange behavior with Date() function

  #4  
Jan 30th, 2007
it should be 24 hour time
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb ASP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the ASP Forum

All times are GMT -4. The time now is 12:33 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC