help with dates

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
 

Cableguy

Expert
Licensed User
Longtime 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...

B4X:
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...
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
There is no need to use DateParse as the date comes from the Calendar control:
B4X:
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:
B4X:
daydif = Int((Calendar1.Value - Calendar2.Value) / cTicksPerDay)
 

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
 
Top