date between ?

  • Thread starter Thread starter HotRod
  • Start date Start date
H

HotRod

Can anyone suggest how to go about testing whether a date is between two
other dates? I'd like to know if a date falls in a certain quarter. THANKS
 
You can do it as below example:

Dim a As Date, b As Date, c As Date
a = DateSerial(2005, 1, 1)
b = DateSerial(2004, 1, 1)
c = DateSerial(2003, 1, 1)
If (b < a Or b < c) And (b > a Or b > c) Then
MsgBox "YES! (between)"
Else
MsgBox "NO! (not between)"
End If

You can replace < with <= AND > with >= if you want to
include the limits.

Sharad
 
If the two dates are in A1 and A2, and your test date is in B1, then use

=IF(AND(B1>=A1,B1<=A2),"Yes","No")

--

HTH

RP
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top