Community discussion forum

how to count days from date

Tags: India
  • 1 year ago

    Hi,

    i wanna count days from any date

    for ex:i have to calculate fine amount of student

    book return date is 15/09/2008 and returning at today 23/09/08

    i wanna calculate no of days from 15/09/08 to 23/09/08 (Ans will be 8 days)any date to any date of year

    if there is some inbuilt function or anything to solve it directly?

     

    thanks

     

     

  • 1 year ago

    Use the timespan object to do this. 

    http://msdn.microsoft.com/en-us/library/system.timespan.aspx

    Your code will look something like this: 

    Dim startDate As DateTime = Date.Parse("15/09/2008")
    Dim endDate As DateTime = Date.Parse("23/09/08")
    Dim myTimeSpan As TimeSpan = endDate.Subtract(startDate)
    MsgBox(myTimeSpan.TotalDays)

  • 1 year ago

    Hi

    DateDiff(DateInterval.Day, dt1, dt2)

    I hope this will solve your problem

    Good Luck

    Hari K......

Post a reply

Enter your message below

Sign in or Join us (it's free).

Want to stay in touch with what's going on? Follow us on twitter!