[Lazarus] DateDif function needed

Jürgen Hestermann juergen.hestermann at gmx.de
Sun Nov 10 09:53:25 CET 2013


Am 2013-11-10 06:57, schrieb Hans-Peter Diettrich:
> Jürgen Hestermann schrieb:
>>
>> Am 2013-11-09 13:43, schrieb Michael Van Canneyt:
>>> So what ? Do an EncodeDate() and you're all set.
>>>
>> That would be a real performance hit (i.e. when sorting by date)
>> if you have stored dates in year, month, day... format.
>> Each comparison then needs multiple convertions each time.
>
> Not with ISO date format (yyyy-mm-dd), where a single string compare is sufficient. But certainly a string compare is more expensive than a comparison of two Real values.
>
Of course.
Even the proposed type-casting of such records to large integers would
make it easy to compare two such dates (at least to decide which one is older).

But the original question was about other (diff) functions
for dates in yyyy, mm.. format and Michael's proposal
was to convert such dates into floats on the fly which
I found to be a performance hit.

It seems that two different topics are discussed here:
1.) What is the best format to store dates
2.) *If* format yyyy, mm, dd, mm, ss... was chosen do date functions exist that deal with it

The only solution to 2.) I have read so far was to convert into float date format
and use the existing functions for this format which IMO has a performance issue.
Function that take yyyy,mm,dd,mm,ss,... format directly seem not to exist (in standard libraries).








More information about the Lazarus mailing list