Problem querying two dates...

# Thread: Problem querying two dates...

1. Junior Member
Join Date
Dec 1969
Posts
13

## Problem querying two dates...

Help!!!<BR><BR>I am trying to display some dates where one date is equal to or greater than the other. Both dates are displayed in the same format ie. 11/01/2002 but for some reason when I run the page it ONLY seems to display the dates where the DAY is greater than or equal to the other DAY. It doesn&#039;t seem to search on the MONTH or YEAR!<BR><BR>Can anyone help?<BR><BR>Code:<BR><BR>&#039; Show current DATE<BR><BR>Dim dtNow<BR>dtNow = DATE <BR>dtNow = DoDateTime(dtNow, 2, 2057)<BR><BR>&#039; Show Gas Exp DATE<BR>Dim dtGasExp <BR>dtGasExp = rsPropInfo.Fields.Item("P_GasCertExp").Value<BR>dt GasExp = DoDateTime(dtGasExp, 2, 2057)<BR> <BR>If (dtGasExp) =&#062; (dtNow) then<BR>&#039; Show Gas Exp Date where Gas Exp Date is greater or equal to Current Date.<BR>end if

2. Senior Member
Join Date
Dec 1969
Posts
497

## They may be equal to the same format but..

they are being compared as 2 text strings, you have to compare them as datetimes or the comapare works left to right...<BR>&#039;a99999&#039; is &#060; &#039;b1&#039;<BR><BR>sponge

3. Junior Member
Join Date
Dec 1969
Posts
13

## RE: They may be equal to the same format but..

How do I do this?<BR><BR>

4. Senior Member
Join Date
Dec 1969
Posts
497

## try this...

the "s" is for seconds... meaning at least a second must be different to notice a difference.<BR><BR>If datediff("s",dtGasExp,dtNow) &#062; 0 then<BR>&#039;dtNow is &#062; dtGasExp<BR>elseif datediff("s",dtGasExp,dtNow) &#060; 0 then<BR>&#039;dtGasExp is &#062; dtNow<BR>end if<BR><BR>sponge

5. Junior Member
Join Date
Dec 1969
Posts
13

## RE: try this...

Thanks for your help Sponge but it&#039;s not made any difference at all. This doesn&#039;t seem to query anything as it&#039;s displaying dates which are &#060; the current date!

6. Junior Member
Join Date
Dec 1969
Posts
13

## RE: try this...

Sorry... my mistake! It did work... the &#060; and &#062; were just the wrong way around! Thanks!!!

#### Posting Permissions

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