Solved

how to get next payment date with a query in access 2010

Posted on 2013-01-24
13
608 Views
Last Modified: 2013-01-28
hi

i have a table that i use for to add all my payments that i pay with my credit card, my billing date for the credit card is every day 10 in the month

so if i buy sumething with my credit card on the 09/10/12 my payment date is 10/10/12 but if i buy on the 11/10/12 my payment date is 10/11/12

so how i can with a sql query select the buying date and based on the date in the month to get the date when i will have to pay for this to the credit card company on this month or next?
0
Comment
Question by:bill201
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
  • +2
13 Comments
 

Author Comment

by:bill201
ID: 38815875
i try this sql syntax but it's donsn't give me right result for some reason:

SELECT ActionID, Account, DateAction, Price, daydefaultpayment, Day([dateaction]) AS DayinMonthActionDate, Month([Dateaction]) AS MonthInActionDate, IIf([dayinmonthactiondate]>[datedefaultpayment],[monthinactiondate]+1,[monthinactiondate]) AS MonthPayment
FROM ActionsT
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 38815958
<on the 11/10/12 my payment date is 10/11/12>

you are paying in advance?
0
 
LVL 41

Expert Comment

by:ralmada
ID: 38815970
something like this perhaps?

SELECT 
	ActionID, 
	Account, 
	DateAction, 
	Price, 
	daydefaultpayment, 
	iif(day(DateAction) < daydefaultpayment, month(DateAction), month(DateAction)+1) as MonthPayment
FROM ActionsT 

Open in new window

0
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
LVL 35

Expert Comment

by:YZlat
ID: 38816159
capricorn1, looks like the format is dd/MM/yyyy and not MM/dd/yyyy
0
 
LVL 41

Expert Comment

by:ralmada
ID: 38816170
sorry, I would just add <= there:

SELECT 
	ActionID, 
	Account, 
	DateAction, 
	Price, 
	daydefaultpayment, 
	iif(day(DateAction) <= daydefaultpayment, month(DateAction), month(DateAction)+1) as MonthPayment
FROM ActionsT 

Open in new window

0
 

Author Comment

by:bill201
ID: 38816646
i tried the code but it's still not working

i'm uploading a similar database with a query and i hope that someone will find a solution , (with the sample database the result is totally not understood for me)

thank for all you for your help...
expertexchange.mdb
0
 
LVL 32

Expert Comment

by:awking00
ID: 38822473
iif(datepart('d',purchasedate) < 10,
dateserial(year(purchasedate),month(purchasedate),10)),
dateserial(year(purchasedate),month(dateadd('mm,purchasedate,1)),10)))
0
 
LVL 32

Assisted Solution

by:awking00
awking00 earned 200 total points
ID: 38822482
iif(datepart('d',purchasedate) < 10,
dateserial(year(purchasedate),month(purchasedate),10)),
dateserial(year(purchasedate),month(dateadd('mm',purchasedate,1)),10)))

I don't have access available for testing, so I may have too many parentheses, it might be

iif(datepart('d',purchasedate) < 10,
dateserial(year(purchasedate),month(purchasedate),10),
dateserial(year(purchasedate),month(dateadd('mm',purchasedate,1)),10))
0
 

Author Comment

by:bill201
ID: 38826570
sorry for the late answer i was not in town....

the code has some syntax error, but i'm not able to find the syntax error, i need someone with access available, with sql experience, to look up what is exact the problem with the sytax
thansk alot
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 300 total points
ID: 38826814
test this, run query Q2
expertexchange.mdb
0
 

Author Comment

by:bill201
ID: 38826885
its working thanks alot
0
 
LVL 32

Expert Comment

by:awking00
ID: 38826941
I finally got to test and saw where the problems were. The month interval is 'm' and not 'mm' and the dateadd parameters were in the wrong order (interval, numbertoadd, date) and not (interval, date, numbertoadd) -
Using capricorn1's table, it should have been -
select actionst.id, format([dateaction],"mm/dd/yy") as purchasedate,
iif(datepart('d',[purchasedate]) < 10,
dateserial(year([purchasedate]),month([purchasedate]),10),
dateserial(year([purchasedate]),month(dateadd('m',1,[purchasedate])),10)) as paymentdate
from actionst;
At any rate, thanks for the assist :-)
0
 

Author Comment

by:bill201
ID: 38829581
thanks alot awking00
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
A company’s centralized system that manages user data, security, and distributed resources is often a focus of criminal attention. Active Directory (AD) is no exception. In truth, it’s even more likely to be targeted due to the number of companies …
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question