Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2013-01-24
13
Medium Priority
?
623 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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 800 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 1200 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

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
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 …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

670 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