Problem With DateAdd And Date Range Input Parameters

May 22, 2005

I have created a query where I use the DateAdd function to calculate a date. I have named this calculated field NextVisitDue. The problem is that I'd like to be able to put an input parameter on NextVisitDue so that I can retrieve records within a date range. For some reason, when I do this, the resulting NextVisitDue dates include dates that are outside of the date range. For instance, if [Begin date:] = 1/1/2005 and [End date:] = 6/1/2005, I will get resulting dates in NextVisitDue like 1/12/2006, 10/21/2006, and 10/6/2007. These results are clearly outside of the date range. What follows is the SQL statement...

SELECT tblSpecialist.User, tblSpecialist.FirstName & " " & tblSpecialist.LastName AS Specialist, tblProvider.ManagerOwnerFN & " " & tblProvider.ManagerOwnerLN AS Provider, tblProvider.FacilityName, tblProvider.LastSupervisoryVisit, DateAdd("m",[tblFrequencyCodes.Frequency],[tblProvider.LastSupervisoryVisit]) AS NextVisitDue, tblProvider.VisitFrequencyCode, tblFrequencyCodes.Frequency
FROM tblSpecialist INNER JOIN (tblCaseLoad INNER JOIN (tblArea INNER JOIN (tblProvider INNER JOIN tblFrequencyCodes ON tblProvider.VisitFrequencyCode = tblFrequencyCodes.FrequencyCode) ON (tblArea.AreaCounty = tblProvider.AreaCounty) AND (tblArea.AreaFacilityType = tblProvider.AreaFacilityType) AND (tblArea.AreaZipCode = tblProvider.AreaZipCode)) ON tblCaseLoad.CaseLoadID = tblArea.CaseLoadID) ON tblSpecialist.SpecialistID = tblCaseLoad.SpecialistID
WHERE (((DateAdd("m",[tblFrequencyCodes.Frequency],[tblProvider.LastSupervisoryVisit])) Between [Begin date:] And [End date:]))
ORDER BY DateAdd("m",[tblFrequencyCodes.Frequency],[tblProvider.LastSupervisoryVisit]);

The real interesting thing is that, if I use literal values for the date range criteria, the query results are as expected! For instance, the following works beautifully (but doesn't allow for user input parameters as required)...

SELECT tblSpecialist.User, tblSpecialist.FirstName & " " & tblSpecialist.LastName AS Specialist, tblProvider.ManagerOwnerFN & " " & tblProvider.ManagerOwnerLN AS Provider, tblProvider.FacilityName, tblProvider.LastSupervisoryVisit, DateAdd("m",[tblFrequencyCodes.Frequency],[tblProvider.LastSupervisoryVisit]) AS NextVisitDue, tblProvider.VisitFrequencyCode, tblFrequencyCodes.Frequency
FROM tblSpecialist INNER JOIN (tblCaseLoad INNER JOIN (tblArea INNER JOIN (tblProvider INNER JOIN tblFrequencyCodes ON tblProvider.VisitFrequencyCode = tblFrequencyCodes.FrequencyCode) ON (tblArea.AreaCounty = tblProvider.AreaCounty) AND (tblArea.AreaFacilityType = tblProvider.AreaFacilityType) AND (tblArea.AreaZipCode = tblProvider.AreaZipCode)) ON tblCaseLoad.CaseLoadID = tblArea.CaseLoadID) ON tblSpecialist.SpecialistID = tblCaseLoad.SpecialistID
WHERE (((DateAdd("m",[tblFrequencyCodes.Frequency],[tblProvider.LastSupervisoryVisit])) Between #1/1/2005# And #6/1/2005#))
ORDER BY DateAdd("m",[tblFrequencyCodes.Frequency],[tblProvider.LastSupervisoryVisit]);

Please help!

-CoddFish

View Replies


ADVERTISEMENT

Reports :: Create Report With Parameters - Unit From Combobox And Date Range

Jan 29, 2015

What I have is a single table that I need to create a report from. It has vehicle unit numbers, dates of service, repair details and costs. I am trying to generate a report where I can select a unit from a combobox and enter a date range.

View 1 Replies View Related

Can I Use DateAdd To Refer To A Pre-entered Date?

Apr 20, 2008

Hi again

I've done some searching on this question and it seem everyone is pointing to the DateAdd function, so here is my current problem.

I have a date/time field called SponsorshipContractDate. When a contract is signed the date is entered. I need the system to calulate the renewal date for the contract which is alway 1 year ahead.

The DateAdd function works only if I hard code at date into it e.g.

DateAdd ("yyyy", 1, "01-Jan-08")

But as contracts are signed throughout the year this just doesn't work so I tried this:

DateAdd ("yyyy", 1, "SponsorshipContractDate") but the table won't save and this is abviously not right. In my head it makes sense but I don't understand how to get the formula to look at another field during it's calculations

Am I using the wrong function?

I will keep looking around.

Thanks heaps

View 4 Replies View Related

Queries :: Date / Time Query - Return All Records Of Specified Date Or Date Range

Aug 19, 2015

I have a table that has entries recorded with date and time in one field, and I want to have a query that returns all records of a specified date or date range, regardless of the time in the field.

I have tried

Code:
Between [StartDate:] And [EndDate:]

And

Code:
Between [StartDate:] & "00:00" And [EndDate:] & "23:59"

Neither of which work ....

View 13 Replies View Related

Print Date Range On A Report Based On A Non-date Field

Aug 7, 2005

Is there a way to show the earliest and latest dates of a report generated by a non-date field?

E.g. I generate a report based on Food, and it'll list the days that this food is associated with. Is there a way to show the first and last day that appears in this report (i.e. the range of dates that the report shows based on the food selected)

View 2 Replies View Related

Modules & VBA :: How To Check For Start Date In Date Range Only Combo Box Value

Jan 22, 2014

I have some code that filters job raised I have 2 text box's txtdatestart and txtenddate after entering. date range between the too text boxs it shows me all job raised with in the period.i have entered what I would like is filter it again by client field using combo box cboclient so if the user enter's client name in cboclient combo box and date range in txtdatestart and txtenddate it will only show jobs raised with in the date range of the client enter in the combo box but if the combo box is empty show.

Code:

Private Sub cmdPreview_Click()
'On Error GoTo Err_Handler 'Remove the single quote from start of this line once you have it working.
Dim strReport As String
Dim strDateField As String
Dim strWhere As String
Dim lngView As Long
Const strcJetDate = "#mm/dd/yyyy#" 'Do NOT change it to match your local settings.

[code]....

View 6 Replies View Related

Date Range Based On A Record Date

Mar 21, 2007

I am trying to filter out information for an ODBC query I have written, to obviously make it more concise. Because our data is not set up very logically, a lot of my queries are based on text...but that is another story. My current situation starts with a simple make-table query finding certain data within a date range. This is followed up by another simple make-table query to find other specific data within another specified date range. Then I have a cross-tab query between the two tables to locate all the data that shares the same unique identifiers. My problem lies with trying to only pull information from a certain date range. For example, I want information to be included if the data has the same unique identifier as well as falls within +/- 7 days of the received date (dd/mm/yyyy) also listed in one of the tables. Each record will likely have different received dates so I cannot set it as a constant.

Make sense to anyone? I am not confident enough to play around with some expressions...well it is more I haven't been successful at using them correctly.

All help is greatly appreciated.

Thanks,
Jay

View 10 Replies View Related

Selecting A Date Range For A Calc'd Date

Jan 13, 2008

I Have a table that I collect data for numerous ID's. One ID may have 5 dates that is was serviced. It is due to be serviced at set intervals which is calculated from the most recent service date. I'm calculating the next service date in a text box with the DateAdd func. =(DateAdd('m',[Cal Freq],[MaxCalDate])) with the MaxCalDate being a Max func in a different text box for selecting the most recent sevice date. I'm trying to update the [Next Due] field in the [Master Asset] table with the calculated next service date so I can do queries on items that are due service within a date range. If I do an Nex Due Expr1: in the queries to calc the next due service date then do a criteria on that Expr1: such as >=[Start Date] And <=[End Date] it states datatype mismatch? Is there a way to select a requested data range on a calculated type date/time? Or How can I update the [Next Due] filed in a different table?

View 8 Replies View Related

Setting Date Parameters.

Jan 28, 2005

i'm a bit a database novice, and have a fairly simple database in Access2000 that records complaints of different categories with amongst other things 'reported' and 'resolved' date fields.

I have 6 queries/ reports that need to be run periodically, using a 'ReportStartDate' and a 'ReportEndDate'. When i run the reports they all use the same dates.

At present I have these set as parameters in each of the 6 queries, but it is a pain having to type both dates in 6 times, and there is obviously a good chance of me making a mistake in typing the dates 6 times.

What I would like to do is just set the ReportStartDate and ReportEndDate just once, so that it could be used by all queries/ reports.

I was thinking that the best way of doing this would be to enter the 2 dates in a table, but I can't see how this would then be linked to the main data table in the queries. I'm sure there must be a way around it...and i'm probably going about it the wrong way...any pointers would be greatly appreciated before it drives me insane!

View 4 Replies View Related

Open Report With Date Parameters

Feb 27, 2013

I need the following report to open with date parameters. I have the following code, but it doesn't quite work.

When an item is chosen from Modl (a list box) a box pops up asking for LowPop, then another for Start Year and then another for End Year.

Those last two aren't doing what they should. They should restrice the [Date] field to between the years entered as start and end. I would like to put it in the "OpenReport" line, but don't think that's going to work.

Code:
Private Sub Command27_Click()
Dim varItm As Variant
Dim ModelWhere As String
Dim strQuery
Dim LowPop As String
Dim SDate As Date

[Code] .....

View 12 Replies View Related

Problem With Select Query Using Date Parameters

Jan 7, 2008

Below is an example of my table "Current Status"

Manufacturer ID___SN________Current Location__Status Date______Time
A________________1____________Area 1________1/6/2008_______3:15
A________________1____________Area 2________1/7/2008_______2:10 PM
A________________1____________Area 3________1/8/2008_______1:01 PM
B________________2____________Area 3________1/2/2008_______5:00 PM
B________________2____________Area 2________1/3/2008_______3:00 PM
B________________2____________Area 4________1/4/2008_______12:47 PM

How can I design a query that will return each products latest currrent location by date, aka, the third and sixth record???? Thank you, I am relativley new to access and am struggling with this.

View 5 Replies View Related

Modules & VBA :: Set Parameters For Date From Last Monday To Sunday

Jul 31, 2015

How to set parameters for the date being last monday to last sunday

So

Paramaters = Date

Then I need

ParamatersWeek = the last monday to the last sunday ...

View 2 Replies View Related

Date Range Within A Date Range

May 12, 2006

I'm trying to figure out how I can set a parameter on my query to search for any activity that occurs within a month, that falls within a date range. Specifically:

Criteria TextBox: 4/2006

Activity Start: 3/6/2006
Activity End: 5/5/2006

I want this activity to show in my query because the time between start and end occurs during the month of April. It's no problem setting this up for a specific date, ie 4/1/2006, but I don't know how to do it for an activity that occurs all days between 4/1/2006 and 4/30/2006..or for one that starts 4/12/2006 and ends 4/18/2006, or starts 4/12/2006 and ends 5/9/2006. etc.

View 2 Replies View Related

Date Range

Jun 18, 2006

Hi All,

I have a table of data, one of the fields is a date.

What i want to do is be able to have a query that can check if the date falls within a certain range - ie fiscal year and output in another column the fiscal year "code".

Ie: dates between 01/06/05 and 31/05/06 is fiscal year 0506
dates between 01/06/06 and 31/05/07 is fiscal year 0607

Could this query be dynamic so if a new fiscal year begins it would know to make the output the next fiscal year code???

Any help is much appreciated.

Cheers

Rudi

View 1 Replies View Related

Date Range SQL

Oct 10, 2006

I have two tables: tblClasses & tblSchedule. There are joined by ClassID. For each class in the tblClasses there are several records with date field in the tblSchedule. (So each class stored in tblClasses happens on multiple dates stored in tblSchedule).

I want to create a query (SQL view) that would take two date inputs from a form(date range): datefrom & dateto, and return any class of which FIRST day of classes falls in between those dates.

(Or: how can I add a field to my query called [First day of class] that would basically have the value of the first date from the tblSchedule for the joined classID?)

View 2 Replies View Related

How To Use A Date Range

Nov 19, 2007

I need to get records between two dates. Here is my query:

SELECT WGMAHIST_TIMEDTY.TDYPT, WGMAHIST_TIMEDTY.TDYCO, WGMAHIST_TIMEDTY.TDYSSN, WGMAHIST_TIMEDTY.TDYFND
FROM WGMAHIST_TIMEDTY
WHERE WGMAHIST_TIMEDTY.TDYSSN = 464299266
AND WGMAHIST_TIMEDTY.TDYEDT >= #06/29/2007#
AND WGMAHIST_TIMEDTY.TDYEDT <= #09/21/2007#
AND WGMAHIST_TIMEDTY.TDYPT = 1
AND WGMAHIST_TIMEDTY.TDYCO = 8

I am obviously doing it wrong because I keep getting an error that complains about the key work BETWEEN.

How can I make this work? I am using MS Access 2007.

Thanks,
wgma

View 5 Replies View Related

Date Range Using IIf Help

Apr 7, 2008

I have a form with a combo box containing the names of the Months. What I want to do is then pass the Month name to a query as a date range. For example, select "May" from cboMonth and the query will check the date field for "between 05/01/2008 And 05/31/2008"

Here is what I have in my query but it does not show any records when I run it:

IIf([Forms]![Form1]![cboMonth]="May",Between #5/1/2008# And #5/31/2008#)

Is it even possible to use this type of an expression in the query?

Thanks......

View 8 Replies View Related

Date Range Help

Jul 14, 2005

Hello - I am trying to create a FOrm that will allow the user to type in two dates. From these dates a table will be created and displayed in a List Box.

Does anyone have a very simple example of the code

1. I am trying to write two input boxes to variables.
2. On click I am displaying a message box that repeates the values of these two variables
3. When they hit OK I want the records to appear in the ListBox.
4. From this point I will want to get the data to a report of some kind.

I am very new to this and am trying to see if someone has any code examples....

This is the code I have so far.....Actually I cant get passed #2 above. It shows the message box and the text but not the values of the variables...

I dont think I am using the variables right......I dont understand the syntax needed to write an input box value to a variable......

Please Help....

THanks



CODE:

Option Compare Database


Private Sub BeginingDate_BeforeUpdate(Cancel As Integer)

Dim BD As String

BD = BeginingDate.txt


End Sub

Private Sub EndDate_BeforeUpdate(Cancel As Integer)

Dim ED As String

ED = EndDate.txt

End Sub


Private Sub Command5_Click()

Dim var_BeginingDate
Dim var_EndDate

var_BeginingDate = BD
var_EndDate = ED

MsgBox "The Variable is " & var_BeginingDate & " and " & var_EndDate, vbInformation + vbOKOnly


End Sub

View 10 Replies View Related

Queries :: Overlapping Date Parameters - Dropping Data

Feb 24, 2014

I'm trying to create a report that pulls from two tables [tblTelephony] and [tblSales]. All data in my query is limited to a date range entered through a form.

For every record in [tblSales] (showing the agent made a sale) there is a record in [tblTelephony] (showing all the stats for the agent's day worked). [tblTelephony] has one date for each record. [tblSales] has two dates for each record. The sales dates are the date the services were ordered (matches the date worked in [tblTelephony]) and the date the services were installed.

In order to get an agent's MTD Sales stats I have to query the date range on Install dates. MTD Telephony stats are run on the same date range on telephony date. Where I run into an issue is with the sales that are ordered before the date range in question and installed during it.

I've run a separate query to sum the sales installed during the date range and used that sales value in my Telephony query. In order to get my data to show as accurately as possible, I had to create a relationship between the Order Date and the Telephony date. I'm really hoping to find a way to force the sum of sales in sales query to show in the sales column in the telephony query, regardless of the telephony date range and without adding telephony data for dates outside the range.

Example:
Date Range = 2/1/14 - 2/24/14
Telephony Date = 2/3/14
Order Date = 2/3/14
Install Date = 2/14/14
Appears on report

Date Range = 2/1/14 - 2/24/14
Telephony Date = 1/31/14
Order Date = 1/31/14
Install Date = 2/3/14
Does not appear on report

How to get the sale example on the bottom to show without removing the relationship?

View 4 Replies View Related

Input Date By Picking Date From Calender

Jun 14, 2005

I am not a professional programer but would like to do a simple database for my group to track research progress. Is that possible to "pick up a date from drop down calendar" then the date will input to the cell (save in table) in a form, instead of typing it in? I saw that in lots of web sites, but can not figure it out how to do it in Access. Tried "Canendar Contol" and "LANDesk Data control" in the toolbox.

Thank in advance

PK

View 4 Replies View Related

Date Range Query

Aug 25, 2005

I am trying to extract records within a certain date range.

My structure is as follows:

Query 1 = pulls data direct from a table. There is a date field which is in the format YYYYMMDD.

Query 2 = pulls data from Query 1 and amends the date format to:
dd/mm/yyyy

Has anyone any suggestions on how I pull data from query 2 from within a certain date range. i.e 01/01/2005 to 01/05/2005

Thanks

View 4 Replies View Related

Between Date Range Conflict

Oct 2, 2006

I am working with a linked table that has a field [Originated Date]

I have created a query for this table and on the criteria for [Originated Date] I put the following:

Between [Forms]![Date Input]![StartDate] and [Forms]![Date Input]![EndDate]

I am using a pop up calendar to populate [StartDate] and [EndDate] fields on the form.

The format of the Date field in the linked table is "Text" not sure if this is the root of my problem ?

When I run the Query Manually and input the [StartDate] as yyyy/mm/dd and the [EndDate] as yyyy/mm/dd the query returns the desired results; However when I run the query with from the form It does not return the desired results.

It is driving me crazy not sure where the discrepency is ?

View 7 Replies View Related

Query Date Range

Jun 8, 2005

I have a query which requires date parameters, which the user enters into a form. The form enters the parameters into 4 different queries then runs them to produce a report.

This all works fine EXCEPT for one query.

If I enter my desired date range into the query (in this case it is between 01/11/2004 and 30/04/2005) it returns no results. As the only values in the date fields of the table are 01/03/2005 and 01/04/2005 it should return all the records.

However if I enter the date range between 01/01/2005 and 30/04/2005 it works fine. It also works if I enter 01/01/2000 and 31/05/2005 - it just doesn't seem to like the year 2004!!!

The problem occurs whether I enter the parameters from the form or simply type them into the criteria of the query. Any ideas, it's driving me nuts!!

View 4 Replies View Related

Putting In A Date Range

Jul 20, 2005

I'm a beginner to Microsoft Access, and I just started working on a project for a marketing company I work for. I have to build them a pretty straightforward database which has tables including Clients, Contacts, Vendors, Employees, Timesheets, etc. The point is to have any employee be able to work with the database and enter any piece of information they have into it. Again, it's a pretty straightforward database. Right now, I am working on a search form for specific jobs. For example, if they need to design a website for a particular company, that specific website job will be entered into the jobs table. I am working on the search form right now so that they can search for specific jobs and they will come up.

One of the sections of the form is a date range, for date received. For example, this would apply if they wanted to search for all jobs that they received between 1/1/05 and 7/10/05. In the query that I am designing for this form, I have the table entry "Date Received" apply to both of the two boxes in the form (I titled them "What Date Received 1" and "What Date Received 2"... my boss advised me to title the boxes in the search forms "What ___" to not get them confused with the forms displaying the information). In the query, the code I am using right now for Date Received is this:

Between [Forms]![Search Jobs]![What Date Received 1] And [Forms]![Search Jobs]![What Date Received 2]

I've also tried this code:

(Between [Forms]![Search Jobs]![What Date Received 1] And [Forms]![Search Jobs]![What Date Received 2]) Or IsNull([Forms]![Search Jobs]![What Date Received 1]) Or IsNull([Forms]![Search Jobs]![What Date Received 2])


The first code works if I have things entered into these boxes. However, if I try to search and leave these blank, I never get any results. I tried playing around with some "IfEmpty" statements, but none of those worked. The second code doesn't work either. Does anybody know how I should modify this statement so that if the "Date Received" boxes are empty, it just ignores it? Thanks a lot.

View 2 Replies View Related

Date Range Criteria...

Aug 22, 2005

I am wanting to use a query to find dates within a range, like a quarter. Within the criteria I put "[Enter Date:]". I ran the query and tried the "Between..And.." operator and even "<=9/1/05 and >=12/31/05". All I get is an error message saying incorrect syntax or structure. Any questions on how I could set this up so I could perform this search, that would be great.

Thanks. :confused:

View 4 Replies View Related

Count Between Date Range

May 8, 2006

I am trying to run a query on a table [tblMain]. I have an input form where the user enters a date range. I would like to count the Month to Date Sales. The month would be that of the end date (forms!frmflash!enddate). How could I count the number of sales between the first of the month and the end date? Each record has a salesdate1, salesdate2, salesdate3, salesdate4, salesdate5, and salesdate6. I need to look in each of these fields and count the sale if it is between the 1st of the month and the enddate.

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved