473,395 Members | 1,680 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

rebilling and repeating date

Hi!

I have been looking a bit into creating a query with function that repeat a date.

More specifically I want to create a new field named next renewal date based on "Subscription start date" and "Subscription type" weekly, monthly, quarterly.

Any help will be very appreciated.
Jul 6 '10 #1
14 1873
nico5038
3,080 Expert 2GB
Hi victorl,

Looks to me you first have to decide how to record this information.
I guess that on a renewal date there needs to be a record for paying the subscription.
Thus I would expect a tblSubscription and a tblPayRecord.

Now the "Subscription start date" and the "Subscription type" can be used to fill the tblPayRecord with the first record to hold the InvoiceDate and an empty PayedAmount and empty PayedDate.

Getting the idea ?

Nic;o)
Jul 6 '10 #2
Jim Doherty
897 Expert 512MB
@victorl
Based on a table named tblSubscriptions having a structure as follows

RowID......Autonumber
SubscriptionDate....Datetime
SubscriptionType...Text(25)

Subscription type must have a lookup as its source in the table using display control as a combobox with the rowsource type set as a value list having a rowsource containing the following string Weekly;Monthly;Quarterly;Yearly

Create a new module and paste the following into it and save

Expand|Select|Wrap|Line Numbers
  1. Function fn_RenewalDate(strSubScriptionType As String, dtSubscriptionDate As Date) As Date
  2. Dim RenewalDate As Date
  3. Select Case strSubScriptionType
  4. Case Is = "Weekly": RenewalDate = DateAdd("w", 1, dtSubscriptionDate)
  5. Case Is = "Monthly": RenewalDate = DateAdd("m", 1, dtSubscriptionDate)
  6. Case Is = "Quarterly": RenewalDate = DateAdd("q", 1, dtSubscriptionDate)
  7. Case Is = "Yearly": RenewalDate = DateAdd("yyyy", 1, dtSubscriptionDate)
  8. End Select
  9. fn_RenewalDate = RenewalDate
  10. End Function
  11. Sub
Create a query named to your liking then go into SQL window view and paste the following

Expand|Select|Wrap|Line Numbers
  1. SELECT tblSubscriptions.RowID,
  2. tblSubscriptions.SubscriptionDate,
  3. tblSubscriptions.SubscriptionType,
  4. fn_RenewalDate([SubscriptionType],[SubscriptionDate]) AS RenewalDate
  5. FROM tblSubscriptions;

Populate your table and run the query

Regards
Jul 6 '10 #3
Jim Doherty
897 Expert 512MB
@nico5038
Whoops sorry Nico did not see you in here :)
Jul 6 '10 #4
nico5038
3,080 Expert 2GB
No "sorry" needed Jim, we were just "cross posting" :-)
Interesting to see we have different approaches <LOL> and both will help.

Nic;o)
Jul 6 '10 #5
Dear Nico and Jim!
Thank you very much for the help provided.

I am sorry I did not provide enough details to reach out with my point.

I have already done until the combobox as in Jims reply. But then in the end, I want to be able to type a date and find out if I have to send any invoices that date. I was able to find the date using the search I created by typing subscription start date and subscriptions first renewal date but did not get any further.

Just an example: Subscription date = 2010-06-15
I want to get it in my search results for 2010-07-15 .. 2010-08-15 .. 2010-09-15 and so on, is this possible?

Once again thanks.
Jul 7 '10 #6
nico5038
3,080 Expert 2GB
I'm afraid you're trying to complicate the search.
Basically the invoices send are linked to a customer and thus you don't need the exact dates, just using the customer ID to filter the invoices will do. Personally I would use a customer form with a linked subform to the invoices and show these invoices with the invoice date descending, thus the most recent invoices will show on top.

This way you won't have trouble when invoicing for a customer changes from weekly to monthly.....

Getting the idea ?

Nic;o)
Jul 7 '10 #7
Hi!
Yeah I get the idea, just a few short final questions, when using a line like this mentioned
" Case Is = "Weekly": RenewalDate = DateAdd("w", 1, dtSubscriptionDate)

will it be displayed forever ( every week) or just once?

And as well, If I thought the "w" will return weekdays (5 / week) while "ww" returns it every week, correct me if I'm wrong.

Thanks
Jul 7 '10 #8
NeoPa
32,556 Expert Mod 16PB
victorl: If I thought the "w" will return weekdays (5 / week) while "ww" returns it every week, correct me if I'm wrong.
You're not wrong Victor. 'ww' is what you require.
Jul 7 '10 #9
Thanks for the input NeoPa!

Anyone know about for how long it will be repeated?
Jul 7 '10 #10
I am trying out Jims code, as it works to get the next subscription, what should I do when that day has passed, like I subscribe 1st august using weekly subscription, then it will tell me it is renewal on 7th august but when the date 7th august has passed it must show 14th august as renewal otherwise it will remain useless.

And if anyone else may have use of this code,
remember you can add this too

Case Is = strSubScriptionType: RenewalDate = DateAdd("d", strSubScriptionType, dtSubscriptionDate)

and it will allow you to use any custom number of days as subscription type.


Thanks
Jul 7 '10 #11
Any help will be extremely appreciated now, it is my final day with this project and I have to get the loop working, loop the code above, just tell me how to write in order to do it, I think Jim may understand as his code is the one I want to loop. Be assure you will get a donation for this help. Once again, thanx
Jul 7 '10 #12
nico5038
3,080 Expert 2GB
Guess you first need to think through the needed processes to handle all situations.

What happens when a subscriber changes the SubScriptionType from Weekly into Monthly...
This will ruin your search when there's no Monthly record created.

When are the Subscription continuation records created, on forehand or after a payment is received ?

Getting the idea ?

Nic;o)
Jul 7 '10 #13
Jim Doherty
897 Expert 512MB
@victorl
Victor, Your original question did not confuse me, but now I am confused and cannot grasp your thought processes as applied in a real world sense?

I am afraid all we can do here is point you in a direction. We cannot second guess your design principles and strategy unfortunately. Helping on a loop is one thing but how it fits in to the bigger picture is another issue and rather pointless if the fundamentals are skewed at all.

I am not saying this is the case essentially but i certainly dont grasp the overall logic myself as yet (maybe I am having a senior moment)
Jul 8 '10 #14
I fixed it so thank you very much everybody. To be specific, subscription is not its actual use but it was the easiest way to describe it as in order to get some information that were similar enough to help. I already tried asking direct questions about it since it is a companytask database with special requirements but without results, anyhow this helped me a lot so thanks again.
Jul 8 '10 #15

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Gleep | last post by:
Hey Guys, I've got a table called Outcomes. With 3 columns and 15 rows 1st col 2nd col 3rdcol outcome date price There are 15 rows...
1
by: Jon Bosker | last post by:
Hi I am trying to get my timesheet report to look good but my date keeps repeating and I do not want it to. I cannot understand how to implement the Meuchian technique here though it seems to...
9
by: Wescotte | last post by:
Here is a small sample program I wrote in PHP to help illustrates problem I'm having. The data base is using DB2 V5R3M0. The client is WinXP machine using the iSeries Client Access Driver ver...
2
by: tom | last post by:
Hi, I have built an Access DB for a child care business. Family table stores the Family info. Room the different room names, capacity etc. Price stores the various price codes and amounts. The...
4
by: tmountjr | last post by:
I'm developing a database for custodial maintenance. There are certain things that the custodial crew does every day (like dusting and vacuuming), once a week (washing windows), once a month, etc....
4
by: Rob Johnson | last post by:
I have an ASP.Net calendar feature which allows users to add events and configure whether or not they repeat at various frequencies (i.e, daily, weekly, monthly, Sat/Sun, etc.). What I'm looking...
15
by: Khurram | last post by:
I have a problem while inserting time value in the datetime Field. I want to Insert only time value in this format (08:15:39) into the SQL Date time Field. I tried to many ways, I can extract...
15
by: edouard.spooner | last post by:
Hi, I have a tricky SQL query problem that I'm having probs with. I have a table which resembles something like this Date | Price1 | Price2 | Price3 01 Jan 2006 | 100 | 100 | 100 02 Jan...
8
by: Dr Al | last post by:
I have a table with four date fields, some of which may not be filled in based on our data entry needs. I have a criteria set as <date()-180 which is supposed to pull dates older than 180 days ago....
0
by: jrhitokiri | last post by:
QUESTION 1: I'm trying to create a room reservation system for school using wicket and MySQL, and I'm a bit confused with this one. I've already created the user database and rooms database. My...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.