ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   date between ? (https://www.excelbanter.com/excel-programming/320630-date-between.html)

HotRod

date between ?
 
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



Sharad Naik

date between ?
 
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

"HotRod" wrote in message
.. .
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




Bob Phillips[_6_]

date between ?
 
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)


"HotRod" wrote in message
.. .
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






All times are GMT +1. The time now is 01:53 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com