justcallmejohn
New member
- Local time
- Today, 09:21
- Joined
- Jan 19, 2014
- Messages
- 1
Good day,
I have searched the Internet far and wide for hours, looking for a solution to my problem. Background: I am on the weak end of semi-skilled working in Access 2003. I am designing a database for a recreational vehicle park which includes check in/check out information similar to a hotel. This park charges rates based upon the length of stay. A customer receives a discounted rate for staying over a week or over a month. So, if I was to stay there from 1 January 2014 to 8 February 2014, I would pay a monthly discounted rate for one month, a weekly discounted rate for one extra week beyond the month, and then the normal rate for the remaining day. I am placing the formula directly into a query. I have found a formula that solves this problem in Excel but cannot find nor construct a corresponding formula in Access, realizing the differences in syntax between the two. In my Excel example I have a "check in" date cell in cell A1, and a "check out" date cell in B1, then three cells that calculate based upon the two input fields. They are:
D1 (to calculate months): =DATEDIF(A1,B1-(MOD(A1,1)>MOD(B1,1)),"ym")
D2 (to calculate weeks):
=INT(DATEDIF(A1,B1-(MOD(A1,1)>MOD(B1,1)),"md")/7)
D3 (to calculate days):
=MOD(DATEDIF(A1,B1-(MOD(A1,1)>MOD(B1,1)),"md"),7)
Now, in Access, I have reconstructed this scenario in a query with what I assume is the correct format for calculated fields:
Months: DateDiff('m',[CheckIn],[CheckOut])
Weeks: Int(DateDiff("ww",[CheckIn],[CheckOut]-[CheckIn] Mod (1)>[CheckOut] Mod (1))/7)
Days: Days: ((DateDiff('d',[CheckIn],[CheckOut])\7)+((DateDiff('d',[CheckIn],[CheckOut]) Mod 7)))
DaysLeftOver: [Days]-([Weeks]*7)
(The DaysLeftOver field indicates days remainder after weeks are subtracted. This field is used on my form while the Days field is hidden.)
I have tried scads of different solutions but nothing seems to work out properly. I hope that I have explained this sufficiently. Any help will not only assist me but possibly will assist others in the future. I will deeply appreciate your assistance! :banghead:
Cordially,
John
Tucson, Arizona
I have searched the Internet far and wide for hours, looking for a solution to my problem. Background: I am on the weak end of semi-skilled working in Access 2003. I am designing a database for a recreational vehicle park which includes check in/check out information similar to a hotel. This park charges rates based upon the length of stay. A customer receives a discounted rate for staying over a week or over a month. So, if I was to stay there from 1 January 2014 to 8 February 2014, I would pay a monthly discounted rate for one month, a weekly discounted rate for one extra week beyond the month, and then the normal rate for the remaining day. I am placing the formula directly into a query. I have found a formula that solves this problem in Excel but cannot find nor construct a corresponding formula in Access, realizing the differences in syntax between the two. In my Excel example I have a "check in" date cell in cell A1, and a "check out" date cell in B1, then three cells that calculate based upon the two input fields. They are:
D1 (to calculate months): =DATEDIF(A1,B1-(MOD(A1,1)>MOD(B1,1)),"ym")
D2 (to calculate weeks):
=INT(DATEDIF(A1,B1-(MOD(A1,1)>MOD(B1,1)),"md")/7)
D3 (to calculate days):
=MOD(DATEDIF(A1,B1-(MOD(A1,1)>MOD(B1,1)),"md"),7)
Now, in Access, I have reconstructed this scenario in a query with what I assume is the correct format for calculated fields:
Months: DateDiff('m',[CheckIn],[CheckOut])
Weeks: Int(DateDiff("ww",[CheckIn],[CheckOut]-[CheckIn] Mod (1)>[CheckOut] Mod (1))/7)
Days: Days: ((DateDiff('d',[CheckIn],[CheckOut])\7)+((DateDiff('d',[CheckIn],[CheckOut]) Mod 7)))
DaysLeftOver: [Days]-([Weeks]*7)
(The DaysLeftOver field indicates days remainder after weeks are subtracted. This field is used on my form while the Days field is hidden.)
I have tried scads of different solutions but nothing seems to work out properly. I hope that I have explained this sufficiently. Any help will not only assist me but possibly will assist others in the future. I will deeply appreciate your assistance! :banghead:
Cordially,
John
Tucson, Arizona