How many days between two dates

pmu5757

Member
Licensed User
Hello !

I'm trying to find how many days are between two dates (the first one is now, and the second one is in a table).

I've build this :
Int((Now - DateParse (Tftabledonnees.Cell("Date",3)))/10000000/60/60/24)

It seems to work when the two dates are in the same month, but it doesn't work othewise.
It would be fine if someone could help me... and if everybody in this forum could excuse me for my poor english.
Thank you.

Pascal.
 

Rioven

Active Member
Licensed User
Hi, your code will get (-)negative value for future date, (+)positive value for past date. it works ok.
Just make sure of a given date, which is in a correct 'dateFormat' in using 'dateParse' statement.

ex. "9/21/2007", this should be "09/21/2007"
 

alfcen

Well-Known Member
Licensed User
Hello Pascal,
You may wish to replace
10000000/60/60/24
with the constant
cTicksPerDay

You can get rid of negative values with
Abs(x)

No apologies needed for your English :sign0142:

Cheers
Robert
 

pmu5757

Member
Licensed User
Thanks..

Hello,
With your answers, I've found the solution.
Some dates that I used had not the right format (01/01/2007 instead of 01/01/07)
It works well now.
I also use now the constant "cTicksPerDay"

Thank you ! :sign0098:

Pascal
 
Top