Click here to Skip to main content
11,790,613 members (50,604 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: ASP.NET VB.NET
I have an application that stores when projects are due along with a start date and end date. Ex: if it is due on the 1st of each month and the start date is 12-15-2012 and the end date is 03-15-2013, I am inserting a row into sql database for each month. Total of 4 rows.

basically i want to insert the first row with all of the info on the form, then 3 more rows with a due date of the 1st for the next month and so on.


If (value = 2) Then
Dim ddate As Date'DueDate
ddate = Sdate.AddMonths(1.0)'add one month but select the day of the month to insert

i want to use the start date selected on the form and just add 1 month for each row created but select the day of the month to add, the "1st" also

Can anyone help me out?
sorry if this makes no sense, i am verry tired.
Posted 28-Dec-12 6:04am
Sheikh Muhammad Haris at 28-Dec-12 12:46pm
Not clear enough, Do you want to save day name (Monday etc) with each of the three rows or what ?

Also provide details how are you adding first row, so that it would be clear how to add others.
Member 8197993 at 28-Dec-12 13:28pm
i have a DDL of 1-28 for the day due of the month, if i choose 1 for day due, i want to insert a row into my table with the startdate(basically a timestamp) the next row will insert the startdate + 1 month but instead of adding 30 days for the +1month, i want it to insert the next month after the start date with 01 being the day due. Not just add 30 days, i want to actually tell it what day to insert for that month.
Sergey Alexandrovich Kryukov at 28-Dec-12 14:24pm
No a valid question, "Can anyone help me out?". Many will be able to help, if you explain what you really want to do. And ask a question.
Member 8197993 at 28-Dec-12 14:45pm
Ok since this is going nowhere. lets say i do this:
dim d as date
d =
insert into table (duedate) values('" & d.addmonths(1.0).day5 of new month

HOW do i add one month to todays date but select the day i want, not just addmonth?

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You can do it like this:
DateTime date = DateTime.Now;
date = date.AddMonths(1);
// set our next date to be the first of the next month
date = date.AddDays((date.Day - 1) * -1);
string dateText = date.ToShortDateString();

Just use the offset of the day of the month to adjust what day you want.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 345
1 ppolymorphe 299
2 Richard MacCutchan 118
3 Maciej Los 70
4 George Swan 70
0 OriginalGriff 1,154
1 Maciej Los 825
2 KrunalRohit 686
3 ppolymorphe 660
4 CPallini 621

Advertise | Privacy | Mobile
Web01 | 2.8.1509028.1 | Last Updated 28 Dec 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100