Solved

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

Posted on 2013-01-24
13
600 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Archiving Access table older than 6 months 9 39
SYbase 4 31
Correct an issue with a where clause with calculation 2 30
SQL Query assistance 16 25
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
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 …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

773 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