Calculating Dates Between To Date Ranges

Dec 27, 2007

Calculating dates between TWO date ranges:

I've read alot of good things on here regarding the DateDiff function and some other things that have helped me out finding the difference between two dates within the same entry on a table. I have a question regarding finding the difference in days between two entries within the same table.

Example:

test table:

Date ID # Name
1/18/07 1234567 Smith
1/20/07 1234567 Smith
1/23/07 1234567 Smith


Is there a way to find the difference in days between the lowest and highest dates? I want to know how many days are between the first entry and the last entry? In this cae it would be five days. I can do it if the days are in the same entry with the datediff function, but having trouble finding it in this situation. Any pointers?

(Thanks for all the good information on this site, BTW. I've seen a few posts similar to this, but it didn't really answer my question)


Don

View Replies


ADVERTISEMENT

Calculating New Date And Returning Dates Within A Range

May 26, 2005

I am tring to add a number of years to a dob. I'm doing this by adding my
date+years*365.26 I get a string of numbers. I then convert the number in
the next column to actual date again. I'm getting the correct date. I've tried unsuccesfully to use the dateadd function.Now I want my criteria on that column to allow me to return only date in a given to from period of my choosing. I want to determine the date range each time I run the query.

An example would be:

DOB age date I need to follow up
5/15/1935 + 75 = 5/15/2005

Then I request dates between 4/1/05 and 5/30/05 and this date is returned.


I've tried the between_and functions but nothing is returned. I'm guessing it's because the column is still a calculation and not a true date.

I've tried: Adding a column to my query to convert the number string back to
date format (criteria failed to return a result). Adding a second column
that ='s my converted number to date column (criteria failed to return a
result)
And I've tried the make table query and then run another query from the new table. I can't seemto make this happen. I think it's not recognizing my data as a date because it isn't returning any data.
Is ther an easier way to: Add a number of years to a date and have it return
a date and not the number string?
If not is there a better way to convert the string to a date?
Is there a way to get my criteria to recognize the date and return date
between my begin and end dates?

Thanks

View 14 Replies View Related

Calculating Number Of Work Dates From 2 Date Fields

May 29, 2005

In my Query I have a Date Received field and a Date Approved field.

I would like to calculate the number of work days, which excludes weekends, between Date Received and Data Approved fields.

It would be more desirable to calculate the number of work days, excluding weekends and governmnet obsereved holidays.. but I don't know if that can be done... If not I can stick with the number of work days excluding weekends.

How would I go about doing this? I would need to add a new column to my query?

What would I put for the field and criteria? What kind of expression do I use?


Any help will be appreciated, thanks

View 14 Replies View Related

Tables :: Calculating Date Of Birth From Dates In Tables

Nov 8, 2012

I have just started using Access 2010. I need to calculate student's ages from their date of birth to today's date. I have a column set up for the date of birth but can't figure out how to get this figure.

View 2 Replies View Related

True Date Ranges

Nov 6, 2006

I run various queries on a daily basis for multiple date ranges (previous day, week to date, month to date, and year to date). The below criteria allows me to get WTD numbers but it has a flaw. When I run the reports on Monday, this criteria gives me Sunday and Monday's data when I actually want the previous week's data. Does anyone know of an iif statement that basically, says, "If today is Monday, give me last week's data, else give me wtd of the current week?" Right now, I manually change the criteria on Monday morning to hard code the dates and then revert to the formula on Tuesdays but I need to have this completly automated because there are a large number of queries and I don't have time to change them all. Thanks for the help!


Between Date()-Weekday(Date()-1) And Date()-1

View 2 Replies View Related

Counting By Date Ranges

May 19, 2005

I received help on previous threads. Basically, I have built a query to group by course title and then select the number of students that were assigned a course during a specifc time frame. Is there a way to show multiple columns in the query. For example my query now shows, enrollment for March, I would like to column next to it to show enrollment for Feb and then another column for Jan.

This is my current sql view.

PHP Code: SELECT tblContent.Title, Count(*) AS [Students Assigned]
FROM tblProfile INNER JOIN tblContent ON tblProfile.LoginName = tblContent.LoginName
WHERE (((tblProfile.LastName)<>"Demo" And (tblProfile.LastName)<>"Care" And (tblProfile.LastName)<>"Robins") AND ((tblContent.Code) Like "NH*") AND ((tblProfile.Groups) Not Like "*Professional Development Center*" And (tblProfile.Groups)<>"All Users,Professional Development Center") AND ((tblProfile.Delete)<>Yes) AND ((tblContent.Type)="Learning Track"))
GROUP BY tblContent.Title, tblContent.[Date Assigned]
HAVING (((tblContent.[Date Assigned])>=#3/01/2004# And (tblContent.[Date Assigned])<=#3/31/2004#)); 


Thank you in advance for any help you can offer.

View 6 Replies View Related

How To Compare Two Date Ranges

Feb 18, 2013

I have a table with employee names and there start time and stop time for their shift. There is also a start time and stop time which they cant work during their shift. So I have shiftstarttime and shiftstoptime and codestarttime and codestop time. I have to create a table with the employee names and generate a time called outboundtime. This outboundtime starts at a specified time (e.g. 9am) and runs for a specified time (60mins). This outboundtime has to be within the range of the employees shift and cant be within the range of the cant work time. If it was, then it would start after the codestoptime for that employee.

I have been trying "if then statements" but I can't seem to compare a range of time to another range of time. Only a specified time to a range which is making things confusing.

View 1 Replies View Related

Date Ranges In Reports Or Queries???

Aug 23, 2005

Hello,

Am posting this message (also on reports forum) as i dont know whether the problem is at report or query level. Hope you can help.

Hello all, this is probably simple but im new to all this!

I am trying to produce reports that show details for only the past year, at present my reports are bringing up details of all the previous years also. Is there any way you can put conditions on reports ( or should it be in a query) that tells the report to only include dates i.e. today - 365 days. At present i have to change the dates every day both a start and end date. Is this possible?

Thanks

View 2 Replies View Related

Parameter Query With Date Ranges

Dec 15, 2005

I am attempting to create a parameter query to show a specific range of dates of service for my customers. Example: I want to see data from my table from Jan. 1st, 2006 to Feb. 15th, 2006 for any customers serviced in that time frame. In the query I have under my Date field, I have the following in the criteria field: Between [Input Start Date] And [Input End Date]. When I go to the while in the design mode of creating the query on the main menu under Query then to parameters and get my Query Parameters what should be put into the Parameter column and the data type columns and will this allow the user to input any start date and end date and get the information from the master table?

I also need to create a parameter query that will allow viewing of only each months table data. Example: Jan. 1st, 2006 through Jan. 31st, 2006.

Thanks in advance!

View 2 Replies View Related

Newbie Question About Date Ranges

Jan 12, 2007

I must be having a bad day, as I can't get something really simple to work. I have a query, that amoungst other things, I want to select all records between two dates. For instance, the table has a 'ScheduledDate' field, and I have set up two parameters in the query that prompt for 'From' and 'To' parameters.

In design view, I have tried the following in the 'criteria' box for the 'ScheduledDate' field;

>=[From] <=[To]

This doesn't work ~ can anyone point me in the right direction. I've searched the forum, perhaps not using the correct keywords?

All help appreciated.

View 5 Replies View Related

Querying Multiple Date Ranges

Sep 26, 2007

I am trying to put together a quick database for my HR team. I need to be able to pull multiple date ranges to show which employees are up for an annual, 6 month and 90 day review.

Is it even possible to put multiple date ranges in one query, or is this going to get complicated? I have no real database background, and know absolutely no SQL so I'm flyin by the seat of my pants here...

View 2 Replies View Related

Queries :: Applying Calculations To Date Ranges

Aug 10, 2015

I need a query that will relate values to given date ranges. For Example:

Table: TaxTypeRange
Values:
TaxType; FromDate; ToDate; Contact
W2; 1/1/15; 3/31/15; Tom
1099; 4/1/15; 6/30/15; Tom
W2; 7/1/15; 12/31/15; Tom

Table: Bills
Values:
Contact; BillAmount; BillDate
Tom; 1000; 3/31/15
Tom; 1100; 4/30/15
Tom; 1200; 5/31/15
Tom; 1300; 6/30/15
Tom; 1400; 7/31/15

Requirement: For every period where the TaxType = W2 the query should multiply the Bill amount by 1.20, so the result should be something like this:

Query: BillsAndTax
Values:
Contact; BillAmount; BillDate; TotalBill
Tom; 1000; 3/31/15; 1200 (TaxType = W2 so 1000* 1.2)
Tom; 1100; 4/30/15; 1100 (TaxType = 1099 does not apply 1.20)
Tom; 1200; 5/31/15; 1200 (TaxType = 1099 does not apply 1.20)
Tom; 1300; 6/30/15; 1300 (TaxType = 1099 does not apply 1.20)
Tom; 1400; 7/31/15; 1680 (TaxType = W2 so 1400 * 1.2)

Not sure how to set this up the right way.

View 3 Replies View Related

General :: Querying Between Records With Date Ranges Within A Certain Time

Nov 5, 2012

I have not found the solution to this looking elsewhere, but basically what I am trying to do is the following:

person date
1 1/1/2012
1 12/15/2012
2 6/12/2012
1 6/13/2012
2 6/14/2012
3 6/16/2012

I want a query which shows the count or records for which a person has a date within 30 days of each other. This is being queried from a large table in which records would may not be sequential by person. Thus in my example above, the third record for person 1 would be omitted as well as the record for person 3.

View 1 Replies View Related

Queries :: Dlookup Value From 1 Table With Date Ranges From Diff Table With A Single Date?

Mar 12, 2015

i have 2 tables.. 1 with bookings and 1 with a BonusPeriod range.

in the Bookings table there is a field called [ServiceDate]

in the bonus table i have a field called [Period] which is text i also have 2 dates, [StartDate] And [EndDate] i need to Dlookup the Bonus table to return the value of the period table based on where the [ServiceDate] falls.

i dont want to use VBA (i really need it to work within a query that inserts it's data into another table)

i've tried everything but had no joy

Expr1: DLookUp("[Period]","BonusPeriods","[ServiceDate]" Between "#[StartDate]#" And "#[EndDate]#")

Expr1: DLookUp("[Period]","BonusPeriods","[Staff_BookingsAndQuotes_Master].[ServiceDate]" Between "#[StartDate]#" And "#[EndDate]#")

Expr1: DLookUp("[Period]","BonusPeriods","(FormatDateTime([ServiceDate]),"yyyy-mm-dd") Between (FormatDateTime([BonusPeriods]![StartDate]),"yyyy-mm-dd") and (FormatDateTime([BonusPeriods]![EndDate],"yyyy-mm-dd"))))

View 10 Replies View Related

Forms :: Date Ranges - Using Child / Master Fields For Creating Filter

Oct 7, 2013

I have a form which I am using child/master fields to create a filter (see attached pic)

For the date ranges I need these to be

>= Start Date and <= Actual Finish Date

How can I set the criteria for these two fields, so that when someone picks a date it knows it's from or before the date entered.

View 14 Replies View Related

Queries :: Getting Transport Rate Based On Date Ranges Due To Fuel Price Floats

Jan 1, 2015

I have tried search through some forums and but still not able to get desire results.

Table Customer Agreed Transport Rate
Customer > Eff Date > Route > Rate
A > 1 June 2014 > AAA > MYR 99
A > 15 Aug 2014 > AAA > MYR 88
A > 1 June 2014 > BBB > MYR 77
A > 1 Sept 2014 > BBB > MYR 66
B > 5 June 2014 > CCC > MYR 88
B > 20 Oct 2014 > DDD > MYR 100
C > 1 Oct 2014 > EEE > MYR 222

If there is order from Customer A for Route AAA loading on 2 July 2014, I can easy to get answer "MYR 99".

How if I wish to make Route as primary key? (as I understand, Primary key must be unique and no repeat).

View 10 Replies View Related

Calculating Dates

Feb 23, 2006

I have a table "main" with 2 colums (main_id,date_out). This table has a link to the table "refill". This table has 3 colums (refill_id, main_id, refill_date).
Example data:
TABLE MAIN
main_id - data_out
01 - 01/01/2006

TABLE REFILL
refill_id - main_id - refill_date
01 - 01 - 10/01/2006
02 - 01 - 16/01/2006
03 - 01 - 21/01/2006

When I make a simple selectquery with the fields main.date_out and refill.refill_date I become the the next result.
01/01/2006 - 10/01/2006
01/01/2006 - 16/01/2006
01/01/2006 - 21/01/2006

Now the problem.
I have to calculate the days between the main and refill dates
01/01/2006 - 10/01/2006 ( is the same as above)
10/01/2006 - 16/01/2006
16/01/2006 - 21/01/2006

suggestions????......thanks

View 2 Replies View Related

Help With Calculating Dates.

Sep 26, 2006

i'm trying to create a query which looks at the field dateEntered and then returns the previous sunday date of that week.

ex.

dateEntered returnedSundayDate

09/26/2006 09/24/2006

are there built in access functions to figure this out in a query?

please help.

View 2 Replies View Related

Calculating Difference Between Dates

Jun 27, 2005

In access in one field I have one date and in another field I have another date. I want to calculate the number of years.,months and days elapsed between these two date. e.g. suppose in one field I have 30.06.2005 and in other 20.04.2004 then it should show 1 year 2 months and 10 days.

View 14 Replies View Related

Problem With Calculating Dates

Jan 13, 2006

Hello,

I'm trying to get a number of days between an employee's hire date and today's date. The employee is supposed to change levels every year until reaches 6 yrs. The sample employee hired on 11/13/2001 and today's date is 1/13/2006, so it should be only 4 yrs (level 04). I tried assigning the levels with this function DateDiff('d',[STEP TABLE].[Hire Date],Date()) AS [Total days] and also with this code below.

Switch([Total Days] Between 0 And 365,"Lvl 01",[Total Days] Between 366 And 730,"Lvl 02",[Total Days] Between 731 And 1095,"Lvl 03",[Total Days] Between 1096 And 1460,"Lvl 04",[Total Days] Between 1461 And 1825,"Lvl 05",[Total Days]>1825, "Lvl 06", [Total Days]=0,Null)

The function's results gives me 1522 days and according to my code the level is "05" (5 yrs). What am I doing wrong? Should I use a different function to calculate the days, so in this case would be 4 yrs and not 5?

Please help!

thanks,

Pablo:confused:

View 14 Replies View Related

Modules & VBA :: Calculating With Dates

Sep 11, 2013

i want to calculate a date

Code:
Dim enddate As Date
Dim startdate As Date
Dim running_time As Double
startdate = Me.startdate
running_time = Me.running_time
endate = stardate + running time
Me.enddate = enddate

The running time is in year.If i calcluate right now, the System things the running time is in days. How can i say that the running time is in years.

View 5 Replies View Related

Calculating The Elapsed Time Between 2 Dates

Feb 22, 2006

I have attached a really simple db where in a query I'm trying to determine the elapsed time between A sent date and a received date. Can some tell me what I'm doing wrong? Thanks..

View 1 Replies View Related

Calculating Number Of Days Using Dates

Mar 15, 2006

I have a library system and i need to work out the number of days from the date the book was due and the current date. Could anyone help me.

View 2 Replies View Related

Problem With Calculating Days Between Dates

Dec 9, 2005

I have a form with two date fields: "Initiation_date", and "Correction_date". There is a third field called "Duration". I would like to store the values of all three fields in the corresponding table. "Duration" (Long Integer) would be the number of days from "Initiation_Date" to "Correction_Date" if Correction date is there, or to Date() if Correction date is Null.

I can use an unbound text box to get "Duration_cal" using the following as a control source:

=IIf(IsNull([VCor_date]),DateDiff("d",[VInit_date],Date()),DateDiff("d",[VInit_date],[VCor_date]))

But I cannot get that value (No.of Days) in to the "Duration" field. The reason I want to have "Duration" stored as a number is that it is being used in a query for another calculation (total days used for selected records).

Is there a simple way to accomplish this?

Thanks

View 1 Replies View Related

Calculating Difference Between Dates In Different Rows

Nov 18, 2011

I currently have a table that has patient ID (unique record (SSN)) and a date of visit field. The SSN may have numerous rows with different dates of visits. What I am trying to do is a DateDiff function that will retrieve records that are 48 hours apart or 2 days apart. We are tracking patients that return within 48 hours of a previous visit.

View 10 Replies View Related

Queries :: Calculating Difference Between Dates In 2 Rows

Oct 25, 2013

I have a list of client activity - client name, loan ID and loan date. I would like to create a new field that shows the number of days between one loan and the next. If I was doing it in excel, I would need to sort the data by client name and loan date and then calculate the number of days between the loan date of one loan and the loan date of the loan immediately prior to this.

View 14 Replies View Related







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