Solved

Between formula (beginning of month)

Posted on 2016-11-14
11
30 Views
Last Modified: 2016-11-14
Experts, I have a query with a WHERE condition to filter for the following criteria:  +-3 months from Date() but must be from beginning of the month (-3) to the end of the month(+3).  When I run, I am getting a data type mismatch error.  There might be a more simple way to do this than below.

WHERE (((Import_FC_Archive.Date) Between DateSerial(Year("Date"),Month("Date")-3,1) And DateSerial(Year("Date"),Month("Date")+3,0)));

thank you
0
Comment
Question by:pdvsa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
11 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 41886345
remove the "" in the Date and add ()  -- Date()  and add bracket to the Date field -- [Date]

WHERE (((Import_FC_Archive.[Date]) Between DateSerial(Year(Date()),Month(Date())-3,1) And DateSerial(Year(Date()),Month(Date())+3,0)));
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 41886349
you want the date range  8/1/2016  to  1/31/2017  is this correct?
0
 

Author Comment

by:pdvsa
ID: 41886365
HI Rey,

<You want the date range  8/1/2016  to  1/31/2017  is this correct?
Yes

I made the changes and no longer have that error but it returns 0 records.  There are quite a few records in the date range +-3 months.

Let me know what the next step is when yo have a sec.  thank you.
0
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 

Author Comment

by:pdvsa
ID: 41886366
<I made the changes
I copied and pasted
0
 

Author Comment

by:pdvsa
ID: 41886369
<you want the date range  8/1/2016  to  1/31/2017  is this correct?
actually it is to 2/28/17
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 41886383
change this

DateSerial(Year(Date()),Month(Date())+3,0)

with

DateSerial(Year(Date()),Month(Date())+4,0)
0
 

Author Comment

by:pdvsa
ID: 41886408
Ok I made the change to +4 as instructed above.
I still dont get any records returned.

fyi:  I can change the where condition to
Between Date()-90 And Date()+90
and many records are returned.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 41886414
how is your date formatted?

can you upload a copy of the table..
0
 

Author Comment

by:pdvsa
ID: 41886480
Rey, please see attached query in db.
format is short date.

thank you.
between.accdb
0
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 500 total points
ID: 41886495
try doing a compact and repair of your DB

here test this... run QueryTest
between.accdb
0
 

Author Closing Comment

by:pdvsa
ID: 41886548
works perfectly.  I think I had some corruption as you suggested.   thank you sir...
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question