I am having trouble in calculating difference in days between two dates in Asp.Net Can anyone provide me with the logic? Or the code will be much better. Please help Guys!
I am having trouble in calculating difference in days between two dates in Asp.Net Can anyone provide me with the logic? Or the code will be much better. Please help Guys!
Are you using SQL database in your project? If yes then it can be used to perform this calculations. SQL has a function called DATEDIFF.
Syntax :
Hope this is useful, All the best!Code:DATEDIFF ( datepart , startdate , enddate )
May be you should try this out :
Is this what you are looking for?Code:DateTime date1 = new DateTime.Now; DateTime date2 = new DateTime(2009,1,1) TimeSpan ts; ts = date1.Subtract(date2.Date);
The following code may do the work, have a try :
Code:Dim datTim1 As Date = #7/7/2009# Dim datTim2 As Date = #7/10/2009# Dim wD As Long = DateDiff(DateInterval.Weekday, DatTim1, DatTim2) Dim wY As Long = DateDiff(DateInterval.WeekOfYear, DatTim1, DatTim2)
Bookmarks