Date comparison

# Thread: Date comparison

1. Senior Member
Join Date
Dec 1969
Posts
241

## Date comparison

I know this code is wrong but don&#039;t know how to calculate properly any ideas?<BR><BR>if(Date &#060; 07/07/2004) then<BR> mydeliverydate = "14th July 2004"<BR> elseif(Date &#060; 07/23/2004) then<BR> mydeliverydate = "4th August 2004"<BR> elseif(Date &#060; 08/20/2004) then<BR> mydeliverydate = "30th August 2004"<BR> end if

2. Senior Member
Join Date
Dec 1969
Posts
241

## RE: Date comparison

its ok i&#039;ve worked it out<BR><BR>if(Date &#060; DateSerial(2004,07,07)) then<BR> mydeliverydate = "14th July 2004"<BR> elseif(Date &#060; DateSerial(2004,07,23)) then<BR> mydeliverydate = "4th August 2004"<BR> elseif(Date &#060; DateSerial(2004,08,20)) then<BR> mydeliverydate = "30th August 2004"<BR> end if

3. Senior Member
Join Date
Dec 1969
Posts
972

## RE: Date comparison

If you want to compare dates, use the DateDiff function:<BR><BR>If DateDiff("d", Date, DateSerial(2004, 7, 7)) &#060; 0 Then<BR>...

4. Senior Member
Join Date
Dec 1969
Posts
972

## RE: Date comparison

That will work too... probably easier than the solution I suggested ;-)

5. Senior Member
Join Date
Dec 1969
Posts
11,247

## Are you sure you want to hard code dates?

What happens next year or in September? -- do you have to change you code

#### Posting Permissions

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