HI everyone,
string enddate = dgv.CurrentRow.Cells["Date"].Value.ToString();
I have taken date from data grid view as given above. Now i need to write a update query where i need to update the enddate by 1 month and 15 days according to the condition. Therefore could you please tell me how to increment the date.
Loading

Pravin MoreRank #1,419 · 1.2K reputationPosted Sep 14, 2011, 10:44 PM EDT
Hi Ruchi ,
do this by way....
enddate=Convert.TodateTime(enddate);
enddate.AddMonths(1);
enddate.AddDays(15);
i hope this will solve ur problem.
Thanx
pravin
Mamta MRank #268 · 9.4K reputationPosted Sep 14, 2011, 10:41 PM EDT
Assuming you have converted your date from string enddate to a DateTime value dt:
dt = dt.AddMonths(1); then followed by
dt = dt.AddDays(15);
Ruchi R91 reputationPosted Sep 14, 2011, 10:52 PM EDT
can you do me one more favor please. If i need to convert the enddate into MM-dd-yyyy format and remove the time from it. How can i do that?
Pravin MoreRank #1,419 · 1.2K reputationPosted Sep 14, 2011, 11:06 PM EDT
HI try this,
String newdt=enddate.toString()
newdt = String.Format("{0:MM/dd/yy}", newdt);Thanx,
Pravin