How to calculate days in between two datetimepicker..?? [Resolved]

Posted by Rock_Monu under ASP.NET on 8/29/2012 | Points: 10 | Views : 4094 | Status : [Member] | Replies : 5
how to calculate days by two datetimepicker and this days insert in datagridview columns.




Responses

Posted by: Gopesh9 on: 8/29/2012 [Member] Starter | Points: 50

Up
0
Down

Resolved
You can use DateDiff function to calculate the difference between any two date and time values.

Example

DateDiff("d", [FirstDate], [SecondDate]) //Displays the days between the values of the FirstDate and SecondDate fields.
The firstdate and second date will be a DateTime...

Or you can have a look to this site
http://msdn.microsoft.com/en-us/library/b5xbyt6f.aspx

G. S.
.Net Developer

Rock_Monu, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rock_Monu on: 8/30/2012 [Member] Starter | Points: 25

Up
0
Down
@Gopesh9
ok sir,i got it but how to fill in datagridview columns"days diff"from two datetimepicker

Rock_Monu, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Gopesh9 on: 8/30/2012 [Member] Starter | Points: 25

Up
0
Down
Okk, tell me what are the columns there in your dataridview...

G. S.
.Net Developer

Rock_Monu, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rock_Monu on: 8/30/2012 [Member] Starter | Points: 25

Up
0
Down
datagridview have a columns name "presentdays".and in this column fill byy two datetime picker "startdate and enddate".


Rock_Monu, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Gopesh9 on: 8/30/2012 [Member] Starter | Points: 25

Up
0
Down
You can try using DataSet, like, take all the values from the datagridview in the dataset and after that using the columns of startdate and enddate, update the presentdays column.

DataSet ds= ((DataTable)datagrid1.dataSource).DataSet

Like this you will get all the columns in the dataset

private void Columns(DataSet ds)

{
foreach(DataTable table in ds.Tables)
{
foreach(DataColumn c in table.Columns)
{
Console.WriteLine(c.ColumnName);
}
}
}



G. S.
.Net Developer

Rock_Monu, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response