Solved

Between formula (beginning of month)

Posted on 2016-11-14
11
23 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
  • 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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

821 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