/ Forside / Teknologi / Udvikling / VB/Basic / Nyhedsindlæg
Login
Glemt dit kodeord?
Brugernavn

Kodeord


Reklame
Top 10 brugere
VB/Basic
#NavnPoint
berpox 2425
pete 1435
CADmageren 1251
gibson 1230
Phylock 887
gandalf 836
AntonV 790
strarup 750
Benjamin... 700
10  tom.kise 610
limitation of datediff()
Fra : asd987


Dato : 30-12-04 15:13

Hello,

I use datediff() to determine the period between dates. This works
perfectly, but...
Datediff() calculates in days, hours or minutes. Instead of "500 days" as
result I want 1 year, .. months and .. days. Is there a solution in VB6 or
do I need to calculate it myself. If so, anyone a good idea?

Thanks,

Sjoerd



 
 
Tomas Christiansen (31-12-2004)
Kommentar
Fra : Tomas Christiansen


Dato : 31-12-04 00:11

asd987 write:
> Datediff() calculates in days, hours or minutes. Instead of "500 days" as
> result I want 1 year, .. months and .. days.

How many days are there in a year?
How many days are there in a month?

When you calculate years, months, days between two dates, the result may
vary depending on wether you start counting hole years, hole month and the
remaining days or you start counting days, then months, then years. The
result may vary depending on wether you start counting from the lowest date
to the highest date or vice versa.

How do you count the period from 2004-01-31 to 2004-02-29. Is it one month
or 29 days?
What about from 2004-02-29 to 2005-02-28. Is it one year or one day less?

You have to decide how you want to count, and then you can create an
algorithm.
The coding it probably not that hard, but the thinking that must be carried
out before is a little bit harder - for some of us

-------
Tomas


Søg
Reklame
Statistik
Spørgsmål : 177549
Tips : 31968
Nyheder : 719565
Indlæg : 6408820
Brugere : 218887

Månedens bedste
Årets bedste
Sidste års bedste