ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Date issue with if Statement (https://www.excelbanter.com/excel-programming/372266-date-issue-if-statement.html)

Dewey

Date issue with if Statement
 
Hi,

I have a problem that I just can't figure out.

I have a data list and I only want to pick out entries which fall on a
specific date or before that but for some reason its not picking up the
entries. It works if I use an = operand but not for <= operand inorder
to get the previous dates aswell.

syntax

Filter_Date = "27/08/2006"
Data_Date = 'Value taken from workbook

if Data_Date <= Filter_Date then
code
endif

Can anyone shed any light on this??

Thanks

Dwight


Stefi

Date issue with if Statement
 
I experienced a similar problem and I found a workaround, perhaps it helps
also to you:

if Data_Date < Filter_Date +1 then

instead of

if Data_Date <= Filter_Date then

Regards,
Stefi


€˛Dewey€¯ ezt Ć*rta:

Hi,

I have a problem that I just can't figure out.

I have a data list and I only want to pick out entries which fall on a
specific date or before that but for some reason its not picking up the
entries. It works if I use an = operand but not for <= operand inorder
to get the previous dates aswell.

syntax

Filter_Date = "27/08/2006"
Data_Date = 'Value taken from workbook

if Data_Date <= Filter_Date then
code
endif

Can anyone shed any light on this??

Thanks

Dwight



cyberwarrior

Date issue with if Statement
 
Hello Dwight, try using the DATEDIF function as I believe you cannot
compare dates without it.

Dewey wrote:
Hi,

I have a problem that I just can't figure out.

I have a data list and I only want to pick out entries which fall on a
specific date or before that but for some reason its not picking up the
entries. It works if I use an = operand but not for <= operand inorder
to get the previous dates aswell.

syntax

Filter_Date = "27/08/2006"
Data_Date = 'Value taken from workbook

if Data_Date <= Filter_Date then
code
endif

Can anyone shed any light on this??

Thanks

Dwight



Bob Phillips

Date issue with if Statement
 
Filter_Date = DateValue("27/08/2006")

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"cyberwarrior" wrote in message
oups.com...
Hello Dwight, try using the DATEDIF function as I believe you cannot
compare dates without it.

Dewey wrote:
Hi,

I have a problem that I just can't figure out.

I have a data list and I only want to pick out entries which fall on a
specific date or before that but for some reason its not picking up the
entries. It works if I use an = operand but not for <= operand inorder
to get the previous dates aswell.

syntax

Filter_Date = "27/08/2006"
Data_Date = 'Value taken from workbook

if Data_Date <= Filter_Date then
code
endif

Can anyone shed any light on this??

Thanks

Dwight





Dewey

Date issue with if Statement
 
Hey,

Yeah the DateValue modifier fixed my problem.

Cheers for that

Dewey


Bob Phillips wrote:

Filter_Date = DateValue("27/08/2006")

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"cyberwarrior" wrote in message
oups.com...
Hello Dwight, try using the DATEDIF function as I believe you cannot
compare dates without it.

Dewey wrote:
Hi,

I have a problem that I just can't figure out.

I have a data list and I only want to pick out entries which fall on a
specific date or before that but for some reason its not picking up the
entries. It works if I use an = operand but not for <= operand inorder
to get the previous dates aswell.

syntax

Filter_Date = "27/08/2006"
Data_Date = 'Value taken from workbook

if Data_Date <= Filter_Date then
code
endif

Can anyone shed any light on this??

Thanks

Dwight





All times are GMT +1. The time now is 01:25 PM.

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