Hi I need some help I have a variable stored in db which is created when a new person is added it takes the day of todaysDate on the day they register and stores only the day

I would like to use this date as the same day of every month the user is due

i.e dueDate actualDate

so if the user joined on the 20/02/2010 and then makes a payment on the 25/03/2010

I want to be able to add 20/03/2010 to the dueDate and 25/03/2010 as the actualDate

I can get the stored day querying the db how would I then add the current month and year to that date

thanks

M

I do not have the code I was asking if it was possible

thanks

If a user joined Jan 30th, then what would the due date be for February? If I join tomorrow (Sep 31st)?

It can be a tricky business to calculate dates on your own, but you can create a string with the day, month and year that you like and convert it to date.

Edited 5 Years Ago by adam_k: n/a

Hi thanks for the reply I am using the following to store the join date

Dim ctrl As UI.DateTimePicker = CType(sender, UI.DateTimePicker)
        LabelDueDate.Text = ctrl.Value.Day.ToString()

I then store this value in the DB I see what you mean about about the odd dates I guess I could use 4 weeks which would then give me 13 months. or could I use some kind of if else for the oddities

If start date = 30 and new month = February then new date = 28 else if start date = 31 and month = September then new date = 30

is it possible to use the stored value "25" and based on the date.Today 30/08/2011 to create a new date value of 25/08/2011 the new value needs to be in date format as that's what I have set the dateDue column to be

thanks

M

Edited 5 Years Ago by mikejs: n/a

Why don't you like the

dateadd(m,1,start_date)

approach?

PS: What type of db are we talking about?

Read here: http://msdn.microsoft.com/en-us/library/system.datetime.addmonths.aspx
or here: http://msdn.microsoft.com/en-us/library/ms186819.aspx

If you want to show your user the due date when registering or something similar, then use the VB approach. If this is to be used to calculate the users due date, you might want to do it in SQL and save yourself the trouble and time of transfering data from SQL to your app and back.
Both ways will give you the same result.

Edited 5 Years Ago by adam_k: n/a

This article has been dead for over six months. Start a new discussion instead.