Results 1 to 4 of 4

Thread: Calculating difference in days between two dates in Asp.Net

  1. #1
    Join Date
    Jan 2009
    Posts
    44

    Calculating difference in days between two dates in Asp.Net

    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!

  2. #2
    Join Date
    May 2008
    Posts
    2,012

    Re: Calculating difference in days between two dates in Asp.Net

    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 :
    Code:
    DATEDIFF ( datepart , startdate , enddate )
    Hope this is useful, All the best!

  3. #3
    Join Date
    Apr 2008
    Posts
    2,005

    Re: Calculating difference in days between two dates in Asp.Net

    May be you should try this out :

    Code:
    DateTime date1 = new DateTime.Now;
    DateTime date2 = new DateTime(2009,1,1)
    TimeSpan ts;
    ts = date1.Subtract(date2.Date);
    Is this what you are looking for?

  4. #4
    Join Date
    May 2008
    Posts
    2,389

    Re: Calculating difference in days between two dates in Asp.Net

    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)

Similar Threads

  1. Calendar days vs work days
    By Boerseun in forum Microsoft Project
    Replies: 4
    Last Post: 02-07-2014, 10:28 PM
  2. Converting work days to calendar days
    By TheTurner in forum Microsoft Project
    Replies: 12
    Last Post: 02-07-2014, 10:15 PM
  3. Replies: 5
    Last Post: 16-03-2011, 06:22 PM
  4. Replies: 3
    Last Post: 12-01-2011, 05:05 AM
  5. find period in days / hours excluding weekdays between two days?
    By Segvoia in forum Software Development
    Replies: 3
    Last Post: 19-06-2009, 11:17 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,674,458.55531 seconds with 17 queries