Modify

Opened 10 years ago

Closed 9 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 Changed 10 years ago by anonymous

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 Changed 10 years ago by Melba23

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 Changed 10 years ago by c.haslam

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 Changed 9 years ago by Jpm

  • Resolution set to No Bug
  • Status changed from new to closed

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

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The ticket will remain with no owner.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.