Modify

Opened 11 years ago

Closed 11 years ago

#3029 closed Bug (No Bug)

_DateDiff() additional help

Reported by: anonymous Owned by:
Milestone: Component: Documentation
Version: 3.3.12.0 Severity: None
Keywords: Cc:

Description

I suggest the following be added, perhaps to the Remarks section:

This function always returns an integer value.

If the precision of $sStartDate and/or $sEndDate exceeds the precision requested in $sType, the user may expect a floating-point result, but in fact the value is floored, thus returning an integer.

For example, _DateDiff('D','2015/05/16 14:32','2015/05/16 14:31') returns -1.

Attachments (0)

Change History (4)

comment:1 by anonymous, 11 years ago

A better example:

I suggest the following be added, perhaps to the Remarks section:

This function always returns an integer value.

If the precision of $sStartDate and/or $sEndDate exceeds the precision requested in $sType, the user may expect a floating-point result, but in fact the value is floored, thus returning an integer.

For example, _DateDiff('D','2015/05/16 14:32','2015/05/16 14:00') returns -1.

comment:2 by Melba23, 11 years ago

Someone brought up a similar problem with _DateAdd recently. I will have a think about how we might add an explanatory note to the Remarks sections of the Help file pages for the 2 functions.

M23

comment:3 by c.haslam, 11 years ago

Also:

This function can compare a date with a date-time. If $sStartDate is a date-time and $sEndDate is a date (or vice versa), the time is ignored. For example, _DateDiff('D','2015/05/16 14:32','2015/05/17') return 1.

But this is not what the function does in this case: _DateDiff('s','2015/05/16 14:32:12','2015/05/17 14:32') returns 86388, being 24*60*60 - 12, so _DateDiff() could be said to append :00 to 14:32 before doing the comparison. I'm not sure what the author intended.

I see that the _Date and _Now functions do not follow the standards for UDFs, so I guess that they were written in the early days of UDFs.

comment:4 by J-Paul Mesnage, 11 years ago

Resolution: No Bug
Status: newclosed

The function return a double. the time is not ignored.

Modify Ticket

Action
as closed The ticket will remain with no owner.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.