Sign in to follow this  
Followers 0
PredatorXXI

_DateDiff question

4 posts in this topic

Why is the following piece of code always returning error code 2 in _DateDiff function, which according to the documentation means:

2 - Invalid $sStartDate

$dataficheiro = "07-08-2012"
$data = "08-08-2012"
GUICtrlSetData($Label11, $dataficheiro)
$difdata = _DateDiff("D", $data, $dataficheiro)
ConsoleWrite(@error & @CRLF)
ConsoleWrite($difdata & @CRLF)

Share this post


Link to post
Share on other sites



Wrong date fomat?

From the help file:

$sStartDate Input Start date in the format "YYYY/MM/DD[ HH:MM:SS]"

$sEndDate Input End date in the format "YYYY/MM/DD[ HH:MM:SS]"

So try "2012/08/07" ("2012-08-07" will work also)

A-Jay


Rule #1: Always do a backup         Rule #2: Always do a backup (backup of rule #1)

Share this post


Link to post
Share on other sites

Thanks, that's it but I'm trying to compare my system date and an Excel cell date and both are in the format dd/mm/yyyy, do I have to convert it before running DateDiff?

Share this post


Link to post
Share on other sites

Yes, when the help file states that the parameters need to be in the format of "YYYY/MM/DD[ HH:MM:SS]" then every other format will return an error.

Check the forum for functions to convert the date to the desired format - there are a few available!


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0