Queries :: Query For Same Fields / Different Dates

Jul 3, 2013

I have a query that is based on three queries. 2 of those queries have the same fields but return data for different dates. The 3rd query returns the dates needed. In other words, I am trying to return all results from both queries. these are the results I want:

Report_ID Report_Date Contents Approvers
Standard ops 5/1/13 daily operations rpt tom tomlin
royer manuf 7/1/13 syndication rpt rob davis

etc.

These are for year-t0-date. there is a YTD query that returns all dates needed. The other two queries return records on different dates, on is for dates <5/5/13 and the other is for dates >5/4/13. I have listed the SQL below. It returns the correct records, but for the Record_ID it returns -1 in each field instead of the report_ID text. So, I need to get the other fields to show up correctly.

Code:
SELECT [Daily_rpts_YTD_due_before_5_5_2013]![Report_ID] Or [Daily_rpts_YTD_due_after_5_4_2013]![Report_ID] AS [Report ID], due_dates_Daily_YTD.Due_dates
FROM (due_dates_Daily_YTD LEFT JOIN Daily_rpts_YTD_due_before_5_5_2013 ON due_dates_Daily_YTD.Due_dates = Daily_rpts_YTD_due_before_5_5_2013.Due_dates) LEFT JOIN Daily_rpts_YTD_due_after_5_4_2013 ON due_dates_Daily_YTD.Due_dates = Daily_rpts_YTD_due_after_5_4_2013.Due_dates
WHERE (((due_dates_Daily_YTD.Due_dates)=[Daily_rpts_YTD_due_after_5_4_2013]![Due_dates] Or (due_dates_Daily_YTD.Due_dates)=[Daily_rpts_YTD_due_before_5_5_2013]![Due_dates]));

View Replies


ADVERTISEMENT

Queries :: Multiple Dates Fields

Nov 15, 2014

I have a DB that consists of Movie titles and the multiple dates ( as many as 10) on which they will be used in the coming year.I built a flat table with 10 date fields.Then tried to build a relational table with just movie title and dates linked to ID.I cannot work out an ability to SEARCH the Database for a SPECIFIC DATE and get returned a listing of ALL Movie titles that will air on that date,

View 9 Replies View Related

Queries :: Selecting All Date Fields Between Two Dates?

Jul 31, 2013

I'm trying to select a range of relevant dates for an amortization calculation (see my earlier thread on this subject here), but I'm having a bit of trouble making the SQL work.

I have a table called "t_AllMonths" that has only one field: MonthStartDate which contains the first day of the month for a very wide range of months over something like a ten-year period. I'm calculating amort for assets which will be amortized for some subset of those months (defined by the asset's Amort Start Date and Amort End Date). Further complicating matters, the amortization may be suspended during certain "hiatus" periods when the asset it not planned to be in use, and may differ by which business units make use of the asset.

So, I have three tables.

Table: t_Assets
Fields: AssetID (autonumber; primary key), Asset_Name, Asset_Cost

Table: t_AllMonths
Fields: MonthStartDate

Table: t_AmortPeriods
Fields: AmortPeriodID, AssetID, Amt_Period_Num (which I don't expect to use in this), StartDate and EndDate

Right now, I'm just trying to pull the range of dates between the earliest amort start date and the latest amort end date. (Min of StartDate and Max of EndDate, respectively) for a given AssetID.

My sql looks like this:

SELECT t_AllMonths.MonthStartDate,
Min(t_AmortPeriods.StartDate) AS MinOfStartDate, Max(t_AmortPeriods.EndDate) AS MaxOfEndDate,
t_Assets.AssetID
FROM t_AllMonths,
t_Assets INNER JOIN t_AmortPeriods ON t_Assets.AssetID = t_AmortPeriods.AssetID
WHERE ((t_AllMonths.MonthStartDate) Between [MinOfStartDate] and [MaxOfEndDate]);

I keep getting an error message that reads "Run-Time Error 3122: You tried to execute a query that does not include the specified expression MonthStartDate as part of an aggregate function."

View 5 Replies View Related

Queries :: Expression Summing From Fields With Dates

Aug 3, 2015

I am involved in centrally managing a project , a part of which involves employees of certain companies being given a weekly subsidy for study on academic courses. I have successfully set up a table for all the learners and a related table for companies.

Each learner will receive a fixed weekly rate subsidy in the first year, and a lower fixed weekly rate subsidy in the second year. Somebody (not me) will need to check their paychecks to ensure that employees have been paid and all is above board. The learners/employees can start on the programme at any time. I need a way to track this (total claimed amounts, where they're up to etc).

My theoretical solution, is to have a field for each week a learner is on the programme (52 first year, 52 second), and instead of entering a currency amount in the field, the check-person can enter the date they saw the evidence and are happy with it. I thought then if I create a query that searches any dates that fall within the current claim period (eg >01/01/2015, <=Date()), and multiplies field count that fall within those parameters by first/second year subsidy rate if they're in that table. I think my logic is sound, I am just not sure how to write the query/expression, or if it's possible, or if there is a much simpler way to do it.

View 4 Replies View Related

Queries :: DateDiff Function - Calculate Difference In Dates Between Two Fields

Apr 22, 2013

I am trying to calculate the difference in dates between two fields. How do I find the difference in days between field one which contains the date 04/12/2011 and field two which contains the date 04/12/2013? I have tried to use the datediff function, but it keeps telling me it doesn't recognize the field name, even though the spellings correct.

View 3 Replies View Related

Queries :: Return Records Between Dates Based On 2 Date Fields In A Table

Apr 24, 2013

I have a table which includes a start date field and completion date field for housebuilding.

I am trying to extract all records that have either a started date or a completed date between 2 dates supplied by the user. I have tried to use Between on both fields but that doesn't return results between the fields.

It workd if I just do it on EITHER the start date field OR the completion date field so that implies to me that I need to break it into 2 queries, one returning start date recrods and the other returning completion date records but then I would need to have somthing that removes records that appear in both the start date and the completion date results.

View 7 Replies View Related

Queries :: WHERE Statement - Enter Dates Into Date Reported Fields For Results To Show

Sep 11, 2013

I use this

'WHERE ((OperationalRiskEventTable.DateReported)>=Forms!U pdateForm!UDateBegin And (OperationalRiskEventTable.DateReported)<=Forms!Up dateForm!UDateEnd)'

in a query by form.

The problem is that you have to enter a date in the between values for results to show. If I don't enter information into a different field such as Full Name but I enter in 40 into Age then everyone that is 40 years old will show. On the other hand if I enter 40 into the Age field but I leave the Date Reported fields empty then no results will show.

How can I change it so that I don't have to enter dates into the date reported fields for results to show?

View 4 Replies View Related

Queries :: Automatic Dates In Query

Jun 12, 2015

I have a table with tasks in which are allocated to specific staff members. The start date of the task is currently inputted by the user and then an estimated time frame is inputted which automatically enters the planned end date.

When a task is complete a Yes/No box is ticked so that these tasks don't show up on the current list anymore.

I wondered if it is possible, for the second task allocated to a certain person to have the start date automatically inputted depending on the planned end date of the precious task.

So if the planned end date was 12/06/2015 then the start date of the next would be 12/06/2015 and so on.

View 2 Replies View Related

Queries :: Query For Records Between Two Dates

Jun 5, 2013

Only one table : Customer ID,Customer name , subscription period, subscription start date and subscription end date.

I need values where subscription start date is between date1 and date2 and subscription end date is between date 1 and date2.

Detail explanation:

customer1 subscribed from 2-feb 2012 to 2-feb 2013
customer2 subscribed from 5-aug-2012 to 5-aug-2013
customer3 subscribed from 1-Jan-2013 to 31-Dec-2013
when the user enters date 1 as 1-jan-2013 and date 2 as 30-Jun-2013

Even though the subscription start date is not within the range entered by the user.I need to get all three customers because the subscription enddate falls within the range.And customer 3 is also required as subscription start date is within the range.

View 2 Replies View Related

Queries :: Calculate Expiry Dates Of Training Courses - Due Dates Not Shown

Aug 28, 2013

I have built a query to calculate the expiry dates of training courses but I am trying to input a criteria so that only dates within 90 days of todays date show. I am using Date()<90 but it doesn't return the correct information. What the criteria should be for this?

View 1 Replies View Related

Queries :: Query To Filter Records Between Dates

Feb 19, 2015

I have a few queries which are used to create reminder email on training which is due for renewal.Some training required reminder 6 months before 2 year expiry. I use this in the criteria for the training date within query:

Between DateSerial(Year(Date()),Month(Date())-18,1) And DateSerial(Year(Date()),Month(Date())-17,0)

Some training required reminder 3 months before 1 year expiry. I use this in the criteria for the training date within query:

Between DateSerial(Year(Date()),Month(Date())-9,1) And DateSerial(Year(Date()),Month(Date())-8,0)

My problem is with training requiring reminder 6 months before 3 year expiry. Using this criteria:

Between DateSerial(Year(Date()),Month(Date())-30,1) And DateSerial(Year(Date()),Month(Date())-29,0)

Doesn't show any results (although there is training which was done 30months ago, expiring in 6 months time).

Changing the -30 (months) and -29 (months) in above down to -22 & -21 shows records as expected, but anything below -22/-21 doesn't show any records.

View 3 Replies View Related

Queries :: Filter Query By Year Of Dates?

Jan 23, 2014

I'm trying to filter an append query by a year selected in a combo box [cboYear] for a field [ProgramDate]. The AfterUpdate on the cbo filters the append query based off of the selection (or selections-I'm using multiple combo boxes on the form). I then run a report based off of the appended table for a report.

I set my criteria for [ProgramDate] the query to be:

Code:

Year([ProgramDate])=[Forms]![frm_rpt_Programs]![cboYear]

The above code isn't working, even when I just try to run the query while the form is open. It's still returning all records.

View 2 Replies View Related

Queries :: Crosstab Query Using Dates For Next 12 Months

Jun 23, 2014

I want to create a cosstab query with dates for the next 12 months accross the top as columns and employee names down the side as rows. I then want to populate with data showing what each person is programed to do under the dates. For instance trainer 1 is delivering training from the 23/06-30/06 then designing a course from 02/07-10/07. that type of thing.

I could represent an activity using a colour i.e. yellow for delivery, green for design etc.

Also do I need to create a table with all the dates? Is there a quick way of doing this?

View 7 Replies View Related

Queries :: Multiple Counts Between 2 Dates In 1 Query

Mar 4, 2015

I have a list of dates and I want 1 query which counts the dates between numerous criteria. for example, colum 1; dates between 1/1/14 and 16/02/2014. Colum2 between 17/02/2014 and 15/04/2014.

I have attached a screenshot.

View 4 Replies View Related

Queries :: CountIf Between Dates In Crosstab Query

Nov 4, 2013

I have generated a table using a crosstab query and it gives the information as below

12/10 12/11 12/12 13/01
Part 1 1 2
Part 2 4 4 4
Part 3 5

So basically part, qty used, year/month used - it works fine up to this point.

Now I want to either add more columns to the crosstab query to count number of times Part 1 was used in last 12 months & 24-13 months

Or

Create another query to do this.

But I want the count function to start counting from current month to last 12 months and from month 13 to month 24 (in another column).

The problem I am having is that this query will run every month and I don't want to update the column headers (in query property sheet) instead I want query to pick this up automatically.

I use the design view to generate queries.

View 1 Replies View Related

Queries :: Update Query To Change Dates

Apr 17, 2015

I'm working on a report that highlights employees when they are leaving on travel and returning on travel and my problem is that the report is only run on the weekdays. It highlights all employees that returned yesterday so for instance on Monday's report it only shows people that returned Sunday and not Friday and Saturday.

My first thought was to make an update query convert those days to Sunday in a new column on my table which would then still cause the employee to be highlighted on monday. I made a table with all Fridays and Saturday's in the year and then in the second column is the Sunday Date to update the new field.

I haven't been able to get the update query to work correctly and was wondering if there would be a much easier solution so a person wouldn't continually extend the weekend table manually.

View 3 Replies View Related

Queries :: Alternate Rounding On Dates In Query?

Aug 13, 2014

I have a query expression that calculates the number of years between 2 dates using DateDiff. Here is the equation as it is:

BudgetedHQPCalc: Round(DateDiff("yyyy",[DateHired],[DateTerminated]),1)

What I would like this to do, is if the difference is, for example, 1.4, I want the number rounded down, if its 1.6 I want it rounded up, and if its 1.5, i want to use alternate rounding (1.5 down 2, 2.5 up to 3).

Is there an easy way to do this?

View 3 Replies View Related

Queries :: Query Criteria Between Two Dates And Two Times

Sep 1, 2014

I have a table which list a load of items, one field is date and one field is time.I have a form with two date boxes and two time boxes, the idea is for the user to search between the two inputted dates and the two inputted times.This then runs a query for a report to be produced. The problem I having is getting the query to runs both criteria it returns nothing.here is the Where part of the current SQL.

WHERE (((tblIncident.IncDate) Between [Forms]![FRM_SearchMulti]![txtrepdate]
And [Forms]![FRM_SearchMulti]![TxtrepDateB]) AND ((tblIncident.IncTime) Between [Forms]![FRM_SearchMulti]![txtreptimea]
And [Forms]![FRM_SearchMulti]![txtreptimeb]))ORDER BY tblIncident.IncDate, tblIncident.IncTime;

View 7 Replies View Related

Queries :: How To Make Certain Range Of Dates For Query To Run

Oct 9, 2013

I have a query and I want to make a certain range of dates for the query to run. For example: from 10/6 to 10/7. What would be a parameter for this range of date? Should I put it on a query?

View 11 Replies View Related

Queries :: Dates Not Changing - Incomplete Query Clause

Jan 17, 2014

I have a date field NxtAPayDate that I need to update to the same day in the next calendar quarter. I have an update query set up using DATEADD but it does not change the dates. The table name is AutoPay

I am using the Query Design Grid. This is the SQL code behind the query:

UPDATE AutoPay SET AutoPay.NxtAPayDate = DateAdd("q",1,[AutoPay]![NxtAPayDate]);

When I view the results the dates are the same - original dates, when I try to sort the results, I get a message box with the following: syntax error, incomplete query clause?

I cannot get the dates to change by using a specific date either

UPDATE AutoPay SET AutoPay.NxtAPayDate = #1/2/2014#;

View 1 Replies View Related

Queries :: Changing Query In VBA Not Working With Calculated Dates?

Sep 9, 2013

I am trying to run a change an existing query in real time to allow date filtering for 4 different categories. I can get two of them to work. Calibration Date and Icepoint Date. But for The two calculated fields Calibration due date and Icepoint date I cannot get it to filter properly e.g. for 2013 dates it also includes 2014 dates and just does not work properly. I am thinking its due to it being a calculated field but don't have a clue how to fix it. see pasted code for calibration due date filter where Todate and Fromdate are the 2 dates used. I also have the on current code and the exit code to reset the query to its original status.

Public Sub SetDate1()
'Apply date filter and rebuild query in real time
On Error GoTo Err_SetDate1
If IsNull(Me!ToDate) And IsNull(Me!FromDate) Then
MsgBox ("Please Enter Date First"), vbExclamation
GoTo Exit_SetDate1

[code]....

View 3 Replies View Related

Queries :: Totals Query - Return Data Set Between Two Dates

Jun 9, 2015

I am trying to create a Totals Query which returns a data set between two dates. So far I have managed to select the data I want (Please see attached screenshot). However, I only want to select records between a date range working on my field [DueDate]. If I add the due date field to the current query then it removes the grouping and all records are displayed.

View 7 Replies View Related

Queries :: Updating Dates - Query Turned Read Only

Mar 28, 2014

I have a query that i use to update dates relating to jobs and at what stage of development they are in. It worked fine until I started to pull in some data (Prism) to update the user when the project is planned in to sample and when mass production starts (the field this is displayed in is not enabled). when I've incorporated this it I have no longer been able to update any field and my query has turned read only.

SELECT dbo_NPD_Container.PENumber, dbo_NPD_Container.JobNumber, dbo_NPD_Container.ProjectTitle, dbo_NPD_Container.Status, dbo_NPD_Sales.InitialQuery, dbo_NPD_Sales.InitialQueryDate, dbo_NPD_Sales.SpecificationIssued, dbo_NPD_Sales.ApprovalRecived, dbo_NPD_Sales.TuDrawIssued, dbo_NPD_Sales.TuDeliveryDate, dbo_NPD_Sales.TrialRequestIssued, dbo_NPD_Sales.SampleDate,

[Code] .....

View 2 Replies View Related

Queries :: IIF Statement To Calculate Expiration Dates Within Query

Jun 15, 2015

I'm trying to build a query with an iif statement to calculate expiration dates within a query. For some reason what i'm trying to do is not working as expected.

Here's the situation. Every employees with an exception of two employees in the company has an expiration 2 years after the class took place. The two exceptions are the certified instructors who's training certification is good for three years.

I've created a query with the employeeid, training subject, and maxoftraining date.

I'm trying to write an if statement to give me the expiration date based on the above information. Here's what I have so far; however its not calculating based on the criteria.

Expiration: IIf([tblemployee]![EmpID]=1 Or 2,DateAdd("yyyy",3,[maxoftrainingdate]),DateAdd("yyyy",2,[maxoftrainingdate]))

At this point in time, all "expiration" dates are showing + 3 years rather than just the Employee ID's 1 and 2 and the rest +2 years.

View 2 Replies View Related

Queries :: Unable To Use Between Query Without Pulling Dates Out Of Range

Feb 19, 2014

Unable to use Between query without pulling dates out of range.I

f I set the Criteria to Between [Enter the start date:] And [Enter the end date:] and input the dates 1/2/2014 & 1/15/2014 i'm pulling data for those dates but for year 2011, 2012, 2013 and 2014 as well.

if I enter in Between #1/2/2014# And #1/15/2014# it gives me just the dates I requested.I need to be able to have a user use the macro and just enter in the dates they need data for.

Also, I am using the criteria on a date ime field that I have set up an expression on - CreateDate: DateValue([TABLE]![date])the date in the table is stored with time and I just need to show the date.

View 3 Replies View Related

Queries :: Parameter Query - How To Get Table Contents Between Dates

Feb 3, 2014

I have a parameter that I need to get a table contents between dates. In the query:

Birthdate: XXTable: criteria as follows: Between [Enter Start Date] and [Enter End Date:]

When run it gives me the Error - ! This expression is type incorrectly, or its too complex to be evaluated. For example, a numeric expression may contain too many complicated elements. Try simplifying the expression by assigning parts of the expression to variables

I have tried almost everything. The formatting of the Birthdate is x/x/xxxx or shortdate. Will this affect the input thus affecting the outcome of the query.

View 4 Replies View Related







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