Solved

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

Posted on 2013-01-24
13
593 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
  • 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 119

Expert Comment

by:Rey Obrero
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
 
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 31

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 31

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 119

Accepted Solution

by:
Rey Obrero 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 31

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now