here we subtract the two date start date and end date and store in a variavle in Number of Days Format
//First we extract the ate from data table and store in a variable
string endt=dt.Rows[(dt.Rows.Count - 1)]["DATE_FIELD"].ToString() ; //It gives the END Date in '14-May-2012' Format
string stdt =dt.Rows[0]["DATE_FIELD"].ToString(); // //It gives the Start Date in '14-May-2012' Format
int daydiff = 0; // Initialize the variable
// In the below case we subtract the date and store in a variavle in day format, like how many number of days
daydiff = Convert.ToInt32( Convert.ToDateTime(endt).ToString("yyyyMMdd")) -Convert.ToInt32( Convert.ToDateTime(stdt).ToString("yyyyMMdd"));
No comments:
Post a Comment