473,657 Members | 2,626 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

calculating dates

lee123
556 Contributor
hi there it's been awhile since i have been on this forum but anyway how do you calculate dates in a query so that there are in currency for example:

if a person rents a room from 01/01/07 to 01/01/08 or 01/01/07 to 06/01/07
how would i get the total amount due if the rent was $540.00
in a query.

lee123
Jan 12 '08 #1
4 1498
puppydogbuddy
1,923 Recognized Expert Top Contributor
hi there it's been awhile since i have been on this forum but anyway how do you calculate dates in a query so that there are in currency for example:

if a person rents a room from 01/01/07 to 01/01/08 or 01/01/07 to 06/01/07
how would i get the total amount due if the rent was $540.00
in a query.

lee123
lee,

You can try this:

Select DateIn, DateOut, DateDiff("d", [DateIn], [DateOut]) As RentDays, Rate, RentDays * Rate As AmountDue From YourTable
Jan 12 '08 #2
zaidlig
45 New Member
lee,

You can try this:

Select DateIn, DateOut, DateDiff("d", [DateIn], [DateOut]) As RentDays, Rate, RentDays * Rate As AmountDue From YourTable
That is correct if the rent is $540 per day. If your rent is based on months you'll want to change it to:

Select DateIn, DateOut, DateDiff("m", [DateIn], [DateOut]) As RentDays, Rate, RentDays * Rate As AmountDue From YourTable

Thats assuming you don't prorate months.
Jan 12 '08 #3
lee123
556 Contributor
hi thanks for the reponse but im confused as to where i put this code in the query table?

lee123
Jan 12 '08 #4
puppydogbuddy
1,923 Recognized Expert Top Contributor
hi thanks for the reponse but im confused as to where i put this code in the query table?

lee123
First, you have to replace the non-aliased field names with the actual names used in your table. Then go to the SQL view of a query, paste the SQL, then run your query; modify as needed.
Jan 12 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
12672
by: John | last post by:
hey all..... alright, I am frusterated to the point of throwing my machine out the window (this board went down, trying to find stuff on google, this has been a nightmare) so I hope you guys can help me with a solution. This is what I am trying to do: Pretty much, there are two dates in my database, a start date, and an end
10
6631
by: riki | last post by:
hello, i need to calculate num of days between 2 dates... i get separate parts of dates from html form, then i need to "make" begining and ending date and calculate difference between them... something like this, in sybase: DAYS(YMD(?YEAR?,?MONTH?,?DAY?), YMD(?YEAR1?,?MONTH1?,?DAY1?)) thnx
1
2373
by: jlm | last post by:
I have a form which feeds table (TblEmpLeave) of Employee Leave Time (time taken off for Administrative, Annual, Sick, Compensation leave). I have EmpID, LeaveDate, LeaveType, LeaveHours fields on this form. Any employee can have multiple entries in the table (key fields are EmpID and LeaveID) for multiple dates (John Doe can take 3 days annual leave, then take 3 days sick leave in any given month. I have a BeginningBalance of hours that...
2
2946
by: bufbec | last post by:
I have worked on this for hours and can't come up with a solution. Hope someone can help me. I have a table called TMBS_HMAUDIT_PARMS. this table contains data to tell me how often a person is allowed to receive services for various programs we offer. columns in this table include PROGRAM_NAME, PROGRAM_ID, ALLOWED_PER_MONTHS. In the ALLOWED_PER_MONTHS column, a numerical value of '9' in the 'ALLOWED PER MONTHS' column means a person is...
2
2085
by: Carl | last post by:
Hi, I have a query that produces an output similar to the sample shown below. These records are based on certain criteria and a date range selected from a form. I need to create some kind of calcualtion or record manipulation to do the following: I need to subtract dates from one another, for example for ID 1 I want to find the difference between 24-Jun-04 and 25-Jan-06 for the 2 applications for Person1.
4
1476
by: Yotam | last post by:
Hi, I need some help with JS. I will be grateful, if you can help me out. I have two date fields (check in, check out) and "number of days" field. I want the script to calculate automatically the difference. For example: I have defaults dates, and I want the script to put the difference in "number of days" field. And if the user will change the date, the number of days will change automatically.
9
21379
by: clintonb | last post by:
I'm looking for a way to calculate the number of days between two dates using standard C++ functions. Would it be as simple as just using the difftime() function and then dividing that result by the number of seconds in a day? - Clint
9
2452
by: mankolele | last post by:
Hi all I need an idea on where to start when calculating a total amount betwee n two dates from a database like I want amount of money paid out from 30/03/2004 and 30/07/2004 ,but in the database these dates are not captured as they come they are mixed as some may come two years later to be captured. I have to go throught the database taking in those apropriate dates I need and add them up. I belive I need to use a while loop and add the...
4
1628
by: jnice814 | last post by:
I have created a frmTimesheet form where auditors will enter their hours for audits that they've worked on. I know how to build a very basic, no-frills database, and what I'm trying to accomplish here is a bit beyond my true technical expertise. At this point, the auditor can select his/her name on the primary Form which will filter any/all audits that they have charged time to (subForm). The subForm details the audits, dates, and hours...
2
5850
by: ncsthbell | last post by:
I am having problems getting the end date to calculate correctly. I start with Quarter '03/02', (YY/QTR), for this it means it is for the 2nd qtr of 2003. My goal is to get the begin & end dates for each 'month' in the quarter, hence, I want to calculate the begin & end of the month dates for April, May & June 2003 : so my starting point is: firstMonthBegin = vcBegMM & "/" & vcBegDD & "/" & vcBegYY firstMonthEnd = vcEndMM &...
0
8385
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8303
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8821
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8723
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8502
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8602
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
1601
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.