Jump to content

[SOLVED] _DateDiff() Help


Recommended Posts

Why is this not doing what I tell it to do?

#include <Date.au3>
$odate = "2008/02/31 09:14:18"
$cDate = _NowCalc()
$nDate = _DateDiff("d", $cDate, $odate)
MsgBox(0, "test", " Old Date: "&$odate&@crlf&"Now Date: "&$cDate&@crlf&"---------------------------------------"&@crlf&"Difference in Days: "&$nDate)oÝ÷ ØÚ-zz&^¯Z¶*)íêÞG¦íj)â§ÐZèZ´§uê쵩ÝÛ!¢é]²0¶÷Þ­éÜy·­Á秶¶u¬¬éèÁ©Ý¶j×¢¦ée{h×ë¢fW¢·l¶«y«uç%j·²Úâè®Ø^¦êé¢Ç¬¡ûaÈ^ު笵»­Øî²Û!£.¥«4ÂÜ¢êìz+"Ê+­ç-N¡zZ_W¢²)ÚqË«jײ+l,jëh×6#Include <Date.au3>
_DateDaysInMonth($iYear, $iMonthNum)

for the information on _DateDiff().

I'm using Autoit:

--Production: 3.2.10.0

--Beta: 3.2.11.5

Edited by zackrspv

-_-------__--_-_-____---_-_--_-__-__-_ ^^€ñ†®øÞÿ ë×阮§ wï†høµ† ƒë@®, wï†høµ† †ïmë, @ñd wï†høµ† @ †ïmïdï†ÿ ƒø® !ïƒë. €×阮 ñø†, bµ† ïñ§†ë@d wï†hïñ, ñ@ÿ, †h®øµghøµ† †hë 맧ëñ§ë øƒ !ïƒë.

Link to comment
Share on other sites

Welcome to Earth.

In our world date "2008/02/31" is invalid.

Wow, first off, thanks for the attitude. Though, to be honest, I'm not quite sure where it came from. I was polite in my comments on this forum, I worded my post correctly and in a friendly manner. But, I supose, that is your opinion, and I welcome you to it.

However, as opinions count, I wouldn't quite rule out what I wrote above. While this is EARTH, the _NOWCALC() calc's it in the same method, as you can see below:

Posted Image

So, If i'm not on earth, and Auto.IT functions are not on earth, then um, would you mind explaining to me, in your...attitude-rich...manner as to why it still will not work?

Thanks!

-_-------__--_-_-____---_-_--_-__-__-_ ^^€ñ†®øÞÿ ë×阮§ wï†høµ† ƒë@®, wï†høµ† †ïmë, @ñd wï†høµ† @ †ïmïdï†ÿ ƒø® !ïƒë. €×阮 ñø†, bµ† ïñ§†ë@d wï†hïñ, ñ@ÿ, †h®øµghøµ† †hë 맧ëñ§ë øƒ !ïƒë.

Link to comment
Share on other sites

Wow, first off, thanks for the attitude. Though, to be honest, I'm not quite sure where it came from. I was polite in my comments on this forum, I worded my post correctly and in a friendly manner. But, I supose, that is your opinion, and I welcome you to it.

However, as opinions count, I wouldn't quite rule out what I wrote above. While this is EARTH, the _NOWCALC() calc's it in the same method, as you can see below:

Posted Image

So, If i'm not on earth, and Auto.IT functions are not on earth, then um, would you mind explaining to me, in your...attitude-rich...manner as to why it still will not work?

Thanks!

BTW, i should have also been more specific.

I have tried 2008/03/05 and 2008/02/01 and 2008/01/05 as well, and none of them give anything other than 0; so while 2/31 is invalid, the others still don't work either :)

-_-------__--_-_-____---_-_--_-__-__-_ ^^€ñ†®øÞÿ ë×阮§ wï†høµ† ƒë@®, wï†høµ† †ïmë, @ñd wï†høµ† @ †ïmïdï†ÿ ƒø® !ïƒë. €×阮 ñø†, bµ† ïñ§†ë@d wï†hïñ, ñ@ÿ, †h®øµghøµ† †hë 맧ëñ§ë øƒ !ïƒë.

Link to comment
Share on other sites

28 days in Feb usually, except this yera there is 29. so 02/31 cant work. I tried 02/28 and it worked

The code I used, Exact same as urs except 02/29. result was -33 days

#include <Date.au3>
$odate = "2008/02/29 09:14:18"
$cDate = _NowCalc()
$nDate = _DateDiff("d", $cDate, $odate)
MsgBox(0, "test", " Old Date: "&$odate&@crlf&"Now Date: "&$cDate&@crlf&"---------------------------------------"&@crlf&"Difference in Days: "&$nDate)
Edited by ofLight

There is always a butthead in the crowd, no matter how hard one tries to keep them out.......Volly

Link to comment
Share on other sites

BTW, i should have also been more specific.

I have tried 2008/03/05 and 2008/02/01 and 2008/01/05 as well, and none of them give anything other than 0; so while 2/31 is invalid, the others still don't work either :)

So,

as example:

#include <Date.au3>
$odate = "2008/02/01 09:14:18"
$cDate = _NowCalc()
$nDate = _DateDiff("d", $oDate, $cdate)
MsgBox(0, "test", " Old Date: "&$odate&@crlf&"Now Date: "&$cDate&@crlf&"---------------------------------------"&@crlf&"Difference in Days: "&$nDate)

still comes back as 0 :)

-_-------__--_-_-____---_-_--_-__-__-_ ^^€ñ†®øÞÿ ë×阮§ wï†høµ† ƒë@®, wï†høµ† †ïmë, @ñd wï†høµ† @ †ïmïdï†ÿ ƒø® !ïƒë. €×阮 ñø†, bµ† ïñ§†ë@d wï†hïñ, ñ@ÿ, †h®øµghøµ† †hë 맧ëñ§ë øƒ !ïƒë.

Link to comment
Share on other sites

Wow, first off, thanks for the attitude. Though, to be honest, I'm not quite sure where it came from. I was polite in my comments on this forum, I worded my post correctly and in a friendly manner. But, I supose, that is your opinion, and I welcome you to it.

However, as opinions count, I wouldn't quite rule out what I wrote above. While this is EARTH, the _NOWCALC() calc's it in the same method, as you can see below:

Posted Image

So, If i'm not on earth, and Auto.IT functions are not on earth, then um, would you mind explaining to me, in your...attitude-rich...manner as to why it still will not work?

Thanks!

Hello, anyone there?

It is working! The return is 0 if the function fails and @error is set according to the problem.

As Jos said, the @error returned from _Datediff is 3 which means an invalid end date. So it would be better to use a valid date.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Hello, anyone there?

It is working! The return is 0 if the function fails and @error is set according to the problem.

As Jos said, the @error returned from _Datediff is 3 which means an invalid end date. So it would be better to use a valid date.

The end date is coming from _NowCalc(). The last piece of code posted returns 60 days for me...

Edited by weaponx
Link to comment
Share on other sites

  • Developers

So,

as example:

#include <Date.au3>
$odate = "2008/02/01 09:14:18"
$cDate = _NowCalc()
$nDate = _DateDiff("d", $oDate, $cdate)
MsgBox(0, "test", " Old Date: "&$odate&@crlf&"Now Date: "&$cDate&@crlf&"---------------------------------------"&@crlf&"Difference in Days: "&$nDate)

still comes back as 0 :)

Works nicely for me... what version of AutoIt3 are you running ?

ps. don't get upset when somebody makes a joke about you making a mistake. We all make mistakes and there is no need to get upset about that, just smile.

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Works nicely for me... what version of AutoIt3 are you running ?

ps. don't get upset when somebody makes a joke about you making a mistake. We all make mistakes and there is no need to get upset about that, just smile.

Check out the first post. Is it doing this in both production and beta?

Link to comment
Share on other sites

Works nicely for me... what version of AutoIt3 are you running ?

ps. don't get upset when somebody makes a joke about you making a mistake. We all make mistakes and there is no need to get upset about that, just smile.

Hi,

I'm using Autoit:

--Production: 3.2.10.0

--Beta: 3.2.11.5

The only reason I become upset in these types of support forums, is because I'm honestly asking for help. I don't really expect the attitudes to come from such a good forum as this. But, as I said, he's entitled to his opinion, and I welcome it; it won't stop me from asking for help, or clarifying my position :)

-_-------__--_-_-____---_-_--_-__-__-_ ^^€ñ†®øÞÿ ë×阮§ wï†høµ† ƒë@®, wï†høµ† †ïmë, @ñd wï†høµ† @ †ïmïdï†ÿ ƒø® !ïƒë. €×阮 ñø†, bµ† ïñ§†ë@d wï†hïñ, ñ@ÿ, †h®øµghøµ† †hë 맧ëñ§ë øƒ !ïƒë.

Link to comment
Share on other sites

Hi,

The only reason I become upset in these types of support forums, is because I'm honestly asking for help. I don't really expect the attitudes to come from such a good forum as this. But, as I said, he's entitled to his opinion, and I welcome it; it won't stop me from asking for help, or clarifying my position :)

But, I identified the issue. My update script was putting a @CRLF at the end of the line to be read. Removed that and made the update script use _NOWCALC() instead of anything else and it updates w/o issue.

Thanks :)

-_-------__--_-_-____---_-_--_-__-__-_ ^^€ñ†®øÞÿ ë×阮§ wï†høµ† ƒë@®, wï†høµ† †ïmë, @ñd wï†høµ† @ †ïmïdï†ÿ ƒø® !ïƒë. €×阮 ñø†, bµ† ïñ§†ë@d wï†hïñ, ñ@ÿ, †h®øµghøµ† †hë 맧ëñ§ë øƒ !ïƒë.

Link to comment
Share on other sites

  • Developers

Check out the first post. Is it doing this in both production and beta?

yea, sometimes there is just too much to read. :)

By the way: it is the Enddate that is wrong and is not the one set by _NowCalc(). :)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

yea, sometimes there is just too much to read. :)

By the way: it is the Enddate that is wrong and is not the one set by _NowCalc(). :)

Well his first post had _NowCalc as the start date, then he reposted with _NowCalc as the end date:

#500325

Threw me off.

Link to comment
Share on other sites

  • Developers

Well his first post had _NowCalc as the start date, then he reposted with _NowCalc as the end date:

#500325

Threw me off.

Yea "shit happens", I always claim I have these spells of senility kicking in.

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

yea, sometimes there is just too much to read. :)

By the way: it is the Enddate that is wrong and is not the one set by _NowCalc(). :party:

Si, my origonal update script wrote to the file with:

FileWrite($file, @YEAR&"/"&@MON&"/"&@MDAY&" "&@hour&":"&@min&":"&@SEC&@crlf)

Because I wasn't using _NOWCALC() in the origonal call it just wasn't workin haha, but it's ok now :)

-_-------__--_-_-____---_-_--_-__-__-_ ^^€ñ†®øÞÿ ë×阮§ wï†høµ† ƒë@®, wï†høµ† †ïmë, @ñd wï†høµ† @ †ïmïdï†ÿ ƒø® !ïƒë. €×阮 ñø†, bµ† ïñ§†ë@d wï†hïñ, ñ@ÿ, †h®øµghøµ† †hë 맧ëñ§ë øƒ !ïƒë.

Link to comment
Share on other sites

  • Developers

The only reason I become upset in these types of support forums, is because I'm honestly asking for help. I don't really expect the attitudes to come from such a good forum as this. But, as I said, he's entitled to his opinion, and I welcome it; it won't stop me from asking for help, or clarifying my position :)

Just a closing remark as a reply to this one: I agree when only a joke is made in a way a bully would do, but in this case the joke pointed to the real problem in the posted script... there is a difference there! :)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...