Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

1/31/20001 = 36921 ???? Date to date comparison?

Status
Not open for further replies.

cpuphantom

IS-IT--Management
Jan 8, 2001
58
US
Hi Group,
I'm working on building a database driven site using ASP and an Access database. I am trying to make an IF statement checking to see if a record already exists for a date. If there is a date, the app does nothing, if the record for that date doesn't exist, it inserts a record with default values. The problem is that even when that record with the date exists, the result is always false.

I changed the data type in Access from Date to Number to see its real value. 1/31/2001 became the number 36921. Where did that come from? So I change the data type back to date, and then went to my asp line and changed it to test for 36921 and it finally became true!!! Here is the line I am using:

<%
Function CurrentRecExist(usernm, recdate)

set recset = canvasDB.execute(&quot;select * from tbNumbers WHERE datestamp = 36921&quot;)

if recset.EOF then
CurrentRecExist = FALSE
else
CurrentRecExist = TRUE
end if
End Function
%>

Is there anyway I can replace the &quot;36921&quot; with a variable or date like 1/31/2001 that makes more sense and finally have it return a true when the record does exist instead of always false??? Or is there a
function to convert 1/31/2001 into its numerical equivelent 36921 to test apples with apples?

Any help is completely appreciated...

Thanks,

Reagan
 
This should work:
Code:
SELECT * 
FROM tbNumbers 
WHERE datestamp = '01/31/2001';

Wushutwist
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top