Date Calculations In Access
Sep 10, 2015
I am building a database and in it I need to do date calculations. Without too much detail I input a date based on the built in calender from the date/time field and based on that date I need to have the following data returned into other individual fields: 6 months from that date, the days until that date, 2 months from the date input, 4 months from the date input, 5 months from the date input, 60 days from the end date, 45 days from the end date, 30 days from the end date, and 15 days from the end date.
Example: I input "Sep 10, 2015" and I would get "Mar 10, 2016", "181 Days", "Nov 10, 2015", "Jan 10, 2016", "Feb 10, 2016", "Jan 10, 2016", "Jan 25, 2016", "Feb 9, 2016", "Feb 24, 2016".
I have read through websites regarding date calculations within Access but I cannot find the specifics for the application that I need.
View Replies
ADVERTISEMENT
Jan 7, 2005
Hi there. I'm just jumping into Access and have the following question. In my Purchase Order Table, I have a date field calcualated as text, i.e. "01/12/04". I need to convert this to a date format in my queries so I can do calculations, i.e. 01/12/04 - 01/05/04 = 7 days. Can someone help me with how to convert this text date to a date format. Sorry if this is an easy question. - AJS
View 4 Replies
View Related
Jun 8, 2005
I have an odd problem that has stumped me for several days. I'm working on a form that contains a chart. The chart is based on a query, which is based on another query, which is based on a table. In the top query, I need to put some calculated fields that operate on other fields. But when I try to multiply two fields together, I get Null. I'm pretty confident that the fields I'm operating on are numerical.
The fields of the query should be:
MaxOfEverInSchool
MaxOfSurvivalToGrade
MaxOfEverInSchool
With these being the calculated fields:
MaxOfSurvivalToGradeCum: MaxOfEverInSchool*MaxOfSurvivalToGrade/100
MaxOfCanReadCum: MaxOfEverInSchool*MaxOfSurvivalToGrade*MaxOfCanRea dCum/10000
Any insight would be greatly appreciated--I just can't understand why Access would suddenly refuse to do math.
View 1 Replies
View Related
Mar 7, 2006
Hi
I would like to manipulate some date information. I have a start date field and an end date field and I would like to draw up a schedule for payment where the Acess takes the finished date and the start date to get total days appart then devides this by a value set by the operator. say If the operator wanted 6 paymes then my total days would be devided by 6 giving me the number of days to add on to the start date. Then with these dates a schedule is made up and the code I have tried looks something like this.
Dim valuation1 As Date
Dim valuation2 As Date
Dim valuation3 As Date
Dim valuation4 As Date
Dim valuation5 As Date
Dim valuation6 As Date
Dim valuation7 As Date
Dim valuation8 As Date
Dim valuation9 As Date
Dim valuation10 As Date
Dim valuation11 As Date
Dim valuation12 As Date
Dim startdate As Double
Dim findate As Double
Dim valcounter As Double
'retrieve start date and end date
startdate = CDbl(Me.Start_Date)
findate = CDbl(Me.Completion_Date)
'calculate evaluation periods
Dim valCount As Double
Dim valDays As Double
valCount = CDbl(Me.Valuation)
valDays = (startdate + ((findate - startdate) / valCount))
'Work on entering valuation dates
Do While valcounter < valCount
Select Case valcounter
Case "1"
Me.valuation1 = startdate
Case "2"
Me.valuation2 = startdate
Case "3"
Me.valuation3 = startdate
Case "4"
Me.valuation4 = startdate
Case "5"
Me.valuation5 = startdate
Case "6"
Me.valuation6 = startdate
Case "7"
Me.valuation7 = startdate
Case "8"
Me.valuation8 = startdate
Case "9"
Me.valuation9 = startdate
Case "10"
Me.valuation10 = startdate
Case "11"
Me.valuation11 = startdate
Case "12"
Me.valuation12 = startdate
End Select
valcounter = valcounter + 1
startdate = startdate + valDays
Loop
' this value is to test the interval period
Me.tdays = valDays
I am new to vb and so ths code is not going to be the best or anywhere near but any help would be great.
Thanks
View 1 Replies
View Related
May 29, 2006
Hi
I was wondering if somebody could help with a problem I have come across. I am currently developing a database for a small charity that I work for. The aim of the database is to record when staff undertake counselling.
I have created a query that calculates the current age of a client in the database uing the following expresion:
Age: Date()-[Date of Birth]
The Date of Birth is formated as a Short Date
In the query I have set the format of the column in the query to 'yy'. This then just displays the age of a client. This work fine apart from ages which are less than 30. If the age is less than 30 e.g. 29 it displays the date as 1929.
Does anybody know how I might be able to solve this or an alternative way in which to calculate dates and display it as 'yy'. (Its been a few years since I last work with access so skills a little rusty)
The reason behind the yy is that the monthly & yearly stats have to group by age ranges.
I am using Access XP (2002) SP2.
Many thanks in advance
Tony
View 4 Replies
View Related
Feb 8, 2007
Hi
I have a field for 'deadline' date and I need to show all records where the deadline date is within 7 days of todays date. (Obviously todays date will change daily...)
I have tried subtracting the date from todays date but it doesnt work.
All help appreciated, thanks
Martin N.
View 3 Replies
View Related
Feb 4, 2005
I am trying to work out the time span in days between the day I archived a record and the current date. In simple terms it would look like this:
Me.TimeSpan = Now() - Me.ArchiveDate
Now I know this isnt right, cause I tied it! Can someone put me in the right direction please.
View 5 Replies
View Related
Jul 21, 2005
Hi Guys,
Just a quick request for a bit of help.
Tries a few things but didnt work.
I have a form which has an employee start date.
What I need to do is work out the holiday entitlement of each emplyee.
The math behine this is, if they have been here less than a year,
we do the following.
20 Days holiday entitlement per year, Divided by 52, then multiplyed by the ammount of weeks remaining in the financial year.
eg, (20 / 52 = 0.384615384) * 31 = 11.92
So they would have 12 Days holiday entitlement.
But if they have been here for 12 months or more, they are entitled to the full 20 days holiday.
How would I express this as an expression or query or VBA to calculate this.
I just cant figure it out, especially the if been here 12 months or more.
I have the start date, in a tbl called tbl_employees if that helps. ( also in the form frm_employee_details )
Our financial Year runs from the 1st December - 31st November
Thanks in advance for any help / advice
Max
View 2 Replies
View Related
Jun 30, 2006
Several questions here, trying to lead up to the easiest code...
First is I have a table with some dates, and I need to do some date calculations, but one of the dates I need will vary. So I was thinking of having a parameter ask for it. Is this the best method?
Second, then once I have this date in, I'll need to have it subtract from another dated reference in the table to figure out the numbers of days difference. e.g. 05/31/06 - 05/01/06 = 30 Can you get two dates to subtract like that and come up with a general number field? If so, then will the dates have to be text, converted to numbers, or can stay as dates?
I've tried several methods and have been quite unsuccessful in each attempt.
Thanks
View 4 Replies
View Related
Mar 8, 2007
Hi,
In MS Access i'm trying to calculate the difference between one date time to another. for example
26/04/2007 09:00 am
07/03/2007 10:30 am (Current date time)
This should work out the:
days
hours
minutes
seconds
I did want this to be shown on a form
Thanks
View 2 Replies
View Related
Jun 28, 2005
Hi there
I need to perform a query that works out how far in advance people book holidays. I have the arrival date and also the booking date, and I think I should be using DateDiff. However, I tried to put it in an existing query and it hasn't worked:
SELECT Bookinfx.[Park Name], Bookinfx.[Accom Type], Year([Start Date]) AS FilterYear, Count(Bookinfx.[Park Name]) AS Bookings, DateDiff("d", [Booking Date], [Arrive])
FROM Bookinfx
GROUP BY Bookinfx.[Park Name], Bookinfx.[Accom Type], Year([Start Date])
HAVING (((Year([Start Date]))=2004));
Any help most gratefully received!
View 11 Replies
View Related
Apr 13, 2006
I am trying to write a query that will return all records whose field expiration_date meets my criteria. The criteria is
If expiration_date - 5 years < today's date then.... do you subtract the total days? months? Any help would be appreciated.
Thanks in advance,
Mark
View 2 Replies
View Related
Sep 18, 2013
I tried this Between (Date()+7) And Date()
But was wondering how do I write this in an IIF statement.
I want to get a text field going for example:
IIF Between (Date()+7) And Date() THEN "Certification Alert"
View 1 Replies
View Related
Aug 17, 2005
I need to calculate (in a query) the Actual Time of a job. I have the start date, start time, end date & end time (all separate fields). This seems to works ok by subtracting the start from the end.
Then I need to calculate the Estimated Time (time it should have taken). This is done by taking the Quantiy divided by the Rate-Per-Hour. This seems to work out ok in the Query, e.g., 101000 / 15000 = 6.66667 hours. But when I display this result in a report as a "Short Time", I get 16:00 instead of 6:40. How can I get the correct display?
The other problem is that I need to divide the Estimated Time by the Actual Time. This also gives me wierd results - I suppose because one is a decimal format time and the other is a "Short Time" format. How can I get the correct answer?
View 2 Replies
View Related
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
Sep 28, 2015
I have solved the problems getting values on the subform. I have not in getting values on the subform.For instance, on the one titled phone use the formula in the tutorial is:
=[sbfCustomerRoomUse].[Form]![txtTotalPhoneUse]
#Error results when the doc is put into a form mode.
Now when I input each value in the equation above separately.I still get no entry.
For " = sbfCustomerRoomUse" , I get #Error;
and for "= txtTotalPhoneUse", I get #Name.
CustomerRoomUse and txtTotalPhoneuse are from the subform that was dropped into the customer form in a previous step. It shows that explicitly when designed sbfCustomerRoomUse on the main that CustomerRoomUse come from a subform. This does not seem to need to be done with txtTotalPhoneuse, and I am not sure why. Neither one gives me a desired calculation result.
View 14 Replies
View Related
Aug 24, 2005
I need to be able to use some functions available in excel in an access 2000 database. These include SUM and IF functions. If any one can help me figure out how to do this any help help wouold be greatly appreciated
View 6 Replies
View Related
Feb 18, 2007
Hi
I am currently setting up a data base for my work and was wondering if there is any way to do the following calculation:
I have a database of automatic doors that are contantly being repaired and i want to keep a record of the accumulated costs involved with this.
I have set up a form to update each door and its accociated repair cost, the problem is when i enter the new repair cost access replaces the current cost with the new and i want it to be added to the current cost so the accumulated cost can be bulit up over time.
I hope this makes sense
Any help would be greatly appreciated!!:)
View 10 Replies
View Related
Dec 5, 2007
Hi
Since this is my first attempt at creating a database and I must admit I am needing a wee bit of help with doing a calculation
I have created a database and need to create a Query I think, to calculate the number of places available the maximum places in each group would be 20 and obviously a count of the people going onto each group would be subtracted from the Max places available this would then need to update the available places . I just cant think how to do this any idea would be a great help.:confused:
View 2 Replies
View Related
Sep 19, 2006
Dear All, i have a very simple database with only one table.
The table has three values [Start], [end] and [Total].
The [start] & [end] fileds are numerical.
I am trying to get it so that i can enter the values onto a form, the two values in [start] and [end] need to be added together to give the [total] value.
I can get it to do it on the form but i don't know how i can get the record in the table to be updated.
Does anyone know if this can be done and if so could you advise me where i'm going wrong.
Any help would be most appreciated.
View 5 Replies
View Related
Oct 16, 2006
I have created a form in Access to enter data into a Table. But one of the firelds I need to enter into the Table is calculated from some of the data being entered in the form. I currently use an Update Query to go back and do the calculation and then update the appropriate field. What I would like to do is to do the calculation and update the calculated field while the user is entering the data. (Boy I hope this is making sense!)
If it helps understand what I am trying to do here is an example: The user is entering data for a job we produced. Some of that data is NumberOfPages, PaperSize and JobType. But I also need to take those three pieces of info and calculate the number of square inches. Currently I run a function I wrote via an Update Query that updates the SquareInches field in the table. I was wondering if there was some way to do the calculation on the fly and enter the calculated value into the table while all the other data is being entered. I tried writing a little code to attach to one of the field's OnExit event but I seem to be having a problem getting the values from the fields I have already entered.
If anyone has any suggestions I would sure appreciate hearing them. Thanks!
View 7 Replies
View Related
Jul 22, 2014
How to implement YTD calculations in Access.
Current table:
Property Month RevenueA Jan '13 100
A Feb '13 50
B Jan '14 200
B Feb '14 300
Desired output:
Property Month Revenue YTD revenue
A Jan '13 100 100
A Feb '13 50 150
B Jan '14 200 200
B Feb '14 300 500
I am new to Access programing and have not been able to figure out a query/macro to execute this.
View 3 Replies
View Related
Mar 25, 2006
Erm Hi everyone I'm new.
Sorry about the rather striking title, but I have an assignment with the deadline tomorrow and I need to find out how to perform numeric calculations in access with different fields (i.e. adding numbers, minusing etc.)
Well, I had to make a project at school for my GNVQ ICT, I chose the advanced sales database, since its a project we have to add in our own features and find out about them ourselves. Well I thought I'd create one for my company inside school, I wanted to create a database that would print invoices and monitor all the resources we have. The project has to be in on monday!
However all was going well until I came upon a slight problem, I'm not sure how to do calculations in Microsoft Access!
Well basically this is what I'm aiming at, its nothing too complicated really.
I have a table called RESOURCES which keeps track of all of the stock the company has (e.g. how much paper, how many mugs, tshirts etc.). I want the database to be able to automatically take 1 away from the selected resource when a form is used to file a new order.
E.g.
I have a form asking me the details of the design, In the resources table I have set the quantity of mugs as 100, i.e. I have 100 mugs in stock and available.
I use the form and tell the database that I am making a design which will use 1 mug.
The database then goes to the resource table and takes 1 away from the available stock of mugs making the total mugs available 99.
I then the database to be able to do this automatically, when a checkbox is ticked, when the form is submitted I want it to see which text boxes are ticked and take the correct consequent resources from the RESOURCE table.
I have Access 2003, I have attached the file incase anyone needs it, note that the Forms have NOT been made only the resource, customers and orders tables have been created.
If someone could tell me how to do this I'd be extremely greatful, this is very URGENT I have to hand in the project on Monday!!!
I know I'm asking alot but I'd be really really greatful if someone could help me out!!!
View 4 Replies
View Related
May 3, 2005
Hi ive made a query but instead of calculating the total at the end of each line I want it to add up the total quantity at the end.
For example:
ID Description Quantity
ID Description Quantity
ID Description Quantity
ID Description Quantity
ID Description Quantity
How do i get the query to add up all of those quantities?
View 5 Replies
View Related
Oct 30, 2005
I'm hoping this is a no brainer...I am a complete newbie and self taught so apologies for not knowing the correct techie terms!!
I have a db with products...
Each product has a price (to customer) and cost (to me the seller)
What I want to work out is the margin i.e. price minus cost divided by proce multiplied by 100 to give a margin in percentage terms.
The data is held in a table with a record per product with the price and cost..
I want to build in another fieled per record that calculates the margin...
Thanks very much
Jessica
(I would also like to be able to work out decreasing margins if I was to extend say a 10% or 20% discount to the customer but I guess I shoudl walk before I run!!)
View 3 Replies
View Related
Nov 15, 2005
Hi, I have a database and on one table I have dates stored for certain jobs. I was wondering if anyone knew how to automatically calculate an end date if the start date and duration is entered!
Do I use a certain query?
Hope you can help, Tobi :)
View 2 Replies
View Related