Query Date Criteria to filter Current Year and next 2 years...???? :( (1 Viewer)

farhanleos

Registered User.
Local time
Today, 04:08
Joined
Oct 19, 2017
Messages
38
Gentlemen,

Greetings

I have a query having a date field
I want criteria to show complete current year records and future 2 years records

I am stuck in this please any one can help me out ?

I tried below criteria but it shows just next 2 years data

Between(DateAdd("yyyy",+2,date())) And Date()



Thanks
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 19:08
Joined
May 7, 2009
Messages
19,247
Year([dateField]) Between Year(Date) And DateAdd("yyyy", 2, Date)
 

farhanleos

Registered User.
Local time
Today, 04:08
Joined
Oct 19, 2017
Messages
38
Year([dateField]) Between Year(Date) And DateAdd("yyyy", 2, Date)
by thos criteria I got msg box
the expression is too complex?

sir any other suggestion ?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 19:08
Joined
May 7, 2009
Messages
19,247
WHERE Year([yourDateField]) Between Year(Date()) And Year(Date())+2
 

farhanleos

Registered User.
Local time
Today, 04:08
Joined
Oct 19, 2017
Messages
38
WHERE Year([yourDateField]) Between Year(Date()) And Year(Date())+2

Dear SIr Arnel,

thanks for your support
by this way my actual field with full date removed , and new expression field appears with years only this is nice
but sir actually I want to keep my date field in query , I want to filter that date column with the dates come under current year from January up till next 2 years


hope you get my point ?

Thanks a lot appreciate your support
I feel happy by joining this forum for access
 

farhanleos

Registered User.
Local time
Today, 04:08
Joined
Oct 19, 2017
Messages
38
Thanks you sir it also ok for me thanks a lot ;)
will disturb you for further query
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 19:08
Joined
May 7, 2009
Messages
19,247
hi, the SQL i gave you will do the
filter from jan 1, 2017 to dec 31, 2019 (2 years).

but if you want to be specific and clear you
can change it to:

WHERE [yourDateField] BETWEEN DateSerial(Year(Date()), 1, 1) AND DateSerial(Year(Date())+2, 12, 31)


****
DateSerial will return a True Date.
the syntax is:

DateSerial(YearNumber, MonthNumber, DayNumber)
 

Users who are viewing this thread

Top Bottom