Datediff getting the date inbetween 2 dates and bind it to a gridview

后端 未结 2 924
情歌与酒
情歌与酒 2020-12-10 01:19

I have a table with \'dateborrowed\' and \'datereturned\' column. What I want to do is I want to get the value in between \'datereturned\' and \'dateborrowed\' and bind it t

2条回答
  •  攒了一身酷
    2020-12-10 02:05

    TimeSpan ts = Convert.ToDateTime(dr["datereturned"]) 
                - Convert.ToDateTime(dr["dateborrowed"]);
    
    (ts.TotalDays); // Will return the difference in Days
    

提交回复
热议问题