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
Solved

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

Posted on 2013-01-24
13
601 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 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
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 
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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

809 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