help with dates

Discussion in 'Questions (Windows Mobile)' started by adbftrainer, Aug 31, 2008.

  1. adbftrainer

    adbftrainer Member Licensed User

    I have two input vars. from user using the calendar control, i want to know how many days are between the two dates, and (assign the value to another var. this part i know). Thank you for any help. I love this program, i have been using it for about a week.

    Again Thank you
    sue
     
  2. Cableguy

    Cableguy Expert Licensed User

    You wil need to do 2 operations, first get the date equivalent in ticks...(for both dates), then subtract the dates...this gets you the icks bettwen the dates...
    Overall,something likethis...

    Code:
    daydif=(DateParse(date2)-DateParse(date1))/(86400*10000000)
    Date2: the newst date
    date1: the oldestdate
    daydif=(DateParse(date2)-DateParse(date1)) gets the tick value diference bettween dates
    86400*10000000) is the number of tick in 1 day...
     
  3. Erel

    Erel Administrator Staff Member Licensed User

    There is no need to use DateParse as the date comes from the Calendar control:
    Code:
    daydif = (Calendar1.Value - Calendar2.Value) / cTicksPerDay
    cTicksPerDay is a constant. Its value is the number of ticks in one day.
    If you want a whole number of days use:
    Code:
    daydif = Int((Calendar1.Value - Calendar2.Value) / cTicksPerDay)
     
  4. adbftrainer

    adbftrainer Member Licensed User

    Like Magic

    Thank you again, you answered more than i asked, it was EXTREMELY HELPFUL.
    The code worked like a charm. NEVER have i seen a program that was tailored for the component of my business. I am writing my own. This is very important to me. sue
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice