TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
madhu goud
NA
36
14.4k
How to create month columns in database basedon no.of months
Jul 10 2015 2:32 AM
i have
No of months
Start date
end date in my page
when i give number of months 3 and start date 10/7/2015 then end date will calculated to 10/9/2015 automatically.
And now i want to create extra columns in database i.e June-2015, july and august
in this table or another table
how to create month columns automatically based on Number months and start date,end date
my code is
protected void Button1_Click(object sender, EventArgs e)
{
SqlCommand cmd = new SqlCommand("Insert into monthcal (NoOfMonths,StartDate,EndDate) values (@NoOfMonths,@StartDate,@EndDate)", con);
cmd.Parameters.AddWithValue("@NoOfMonths", txtNoOfMonths.Text.ToString());
cmd.Parameters.AddWithValue("@StartDate", txtStartDate.Text.ToString());
cmd.Parameters.AddWithValue("@EndDate", txtEndDate.Text.ToString());
con.Open();
cmd.ExecuteNonQuery();
}
protected void txtStartDate_TextChanged(object sender, EventArgs e)
{
string inputString = txtStartDate.Text;
DateTime dt = DateTime.ParseExact(inputString, "yyyy/MM/dd", CultureInfo.InvariantCulture);
dt = dt.AddMonths(Convert.ToInt32(txtNoOfMonths.Text));
txtEndDate.Text = dt.ToString("yyyy/MM/dd");
DateTime Date1 = Convert.ToDateTime(txtStartDate.Text);
DateTime Date2 = Convert.ToDateTime(txtEndDate.Text);
//int Datediff = ((Date2.Year - Date1.Year) * 12) + Date1.Month - Date2.Month;
int DayDiff = (Date2.Date - Date1.Date).Days;
Label1.Text = "Total days" + " " + (DayDiff.ToString());
Reply
Answers (
1
)
Ondouble click of datecell gridview should open??
Code show lots of waiting