If date equals today

Results 1 to 2 of 2

Thread: If date equals today

  1. #1
    Join Date
    Dec 1969

    Default If date equals today

    I need a bit of help here. I have a game that pays postage, but the user can only play once per day. I have already created a field in the database that records his last game. That was easy. Now, I want to retrieve the last time he played (I can do that) and compare it with today&#039s date (this is where I need help). The retreived date format looks like this:<BR>8/16/00 8:25:28 PM <BR>How can I make this work: <BR><BR>If userSet("last_play").value = today&#039s date then <BR>response.write "whatever" <BR>end if<BR><BR>That is all I want to do. I know it is easy. But I have no prior code that does this so I need help.<BR><BR>I would love to see an example of last 24 hours (once per 24 hours)<BR>and another example that matches the date (once per calendar date). <BR>I haven&#039t decided which to do yet. Right now I am using cookies which don&#039t expire on AOL browsers, so I want to make it database dependent.<BR><BR>Thanks,<BR><BR>Edward<BR>visit my website for more fun, and win a free greeting card... not one of those crappy virtual cards... a real printed one you can mail to a friend from your browser!<BR>http://www.grannymail.com

  2. #2
    Join Date
    Dec 1969

    Default RE: If date equals today

    Never tried it, but the docs for DateValue look like it would work. And, of course, today is gotten with just plain old Date. So:<BR><BR>&#060;%<BR>If DateValue( userSet("last_play") ) = Date() Then<BR>...<BR>End If<BR>%&#062;<BR><BR>For 24 hours, it&#039s easy:<BR><BR>&#060;%<BR>&#039 find number of hours between two date/times and compare...<BR>If DateDiff( "h", userSet("last_play"), Now() ) &#062; 24 Then<BR>...<BR>End If<BR>%&#062;<BR><BR>What do you mean by "matches the date"???<BR><BR>Anyway, just go to the VBScript Reference manual (there&#039s a link on the left side of this page if you don&#039t have it on your own machine yet) and take a look at all the FUNCTIONs that have the word "date" or "time" in their names. There are a ton of them, and likely one of them will do what you need.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts