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!

Date Comparison 1

Status
Not open for further replies.

mattygriff

Programmer
May 14, 2001
350
GB
How can I compare a date entered into an HTML form with one in an Access database?

The problem is that the CDate function in VBScript produces a different format of date to that held in Access.

Any suggestions?
 
<%
DatetoCheck =&quot;21/09/2001&quot;

YeartoAdd = Right(Year(DatetoCheck),2)
'Last 2 digits of the Year

MonthtoAdd = Month(DatetoCheck)
If inStr(MonthtoAdd,&quot;0&quot;) = 1 then
MonthtoAdd = Right(MonthtoAdd,1)
End If
'If there is a prevailing 0 remove it

DaytoAdd = Day(DatetoCheck)
If inStr(DattoAdd,&quot;0&quot;) = 1 then
DattoAdd= Right(DaytoAdd,1)
End If
'

DatetoCheck = YeartoAdd & &quot;/&quot; & MonthtoAdd & &quot;/&quot; DaytoAdd

SQL = &quot;SELECT Month from Table where Month = #&quot; & DatetoCheck & &quot;#&quot;

adoRS.Open SQL,adoConn

If AdoRS.EOF Then
'Oooh, date doesnt exist in database
Else
'Aaah, date already exists in database
End If

%>

Lazy Bugger

G -GTM Solutions, Home of USITE-
-=
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top