Forum Moderators: open

Message Too Old, No Replies

ASP date function question

         

kevinj

4:15 pm on Aug 29, 2004 (gmt 0)

10+ Year Member



I have an If Then statement that needs to check a variable against today's date. Can't get it to work. Any suggestions would be most appreciated.

If DEACTIVATION_DATE <= Now() Then

Response.Write("Yes")

End if

DEACTIVATION_DATE comes from an Access DB and the field is set as a Date/Time (Short Date) datatype. I have a select statement that works correctly but can't get my if then to work

SELECT * FROM VOLUNTEER_OPPS WHERE DISPLAY_OPP=YES AND DEACTIVATION_DATE <= #" & NOW() & "#

Thanks,

Kevin

duckhunter

4:38 pm on Aug 29, 2004 (gmt 0)

10+ Year Member



Probably just a formatting issue. Have your done a Response.Write on both values?

Response.Write "DeactivationDate: " & DEACTIVATION_DATE
Response.Write "Now: " & Now()

You might need to wrap each value with a FormatDateTime function to return identical formats.

GaryK

4:43 pm on Aug 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Scratch what I wrote before.

In your response.write statement doesn't DEACTIVATION_DATE need to be wrapped in a Recordset reference?

macrost

5:28 pm on Aug 29, 2004 (gmt 0)

10+ Year Member



Unless DEACTIVATION_DATE is a var that contains the info from the recordset.

You should look into the date functions.

[mikecaldwell.com...]

kevinj

5:39 pm on Aug 29, 2004 (gmt 0)

10+ Year Member



Yes, something as stupid as that. I hadn't gotten the value earlier on the page so I need to do RS("deactivation_date")

Thanks!

Kevin