Jump to content

Recommended Posts

Posted

hey all,

i think i have discovered a bug in the _DateAdd function, but im not sure whether it is something im doing

or something that hasnt been tried yet.

CODE

$expirydate=stringleft($expire[3],4)&"/"&$expire[1]&"/"&$expire[2]

;now that date is in format YYYY/MM/DD, calculate 1d before, 1w before

$onedaybefore=_DateAdd('d',-1,$expirydate)

$oneweekbefore=_DateAdd('w',-1,$expirydate)

$todaysdate=stringleft(_NowCalc(),10)

msgbox("","","| date account expires '"&$expirydate&"' | one day before '"&$onedaybefore&"' | one week before '"&$oneweekbefore&"' | todays date '"&$todaysdate&"' | ")

when i run this code on windows xp sp3, i receive a msgbox with the contents;

' | date account expires '2009/03/19' | one day before '2009/03/18' | one week before '2009/03/12' | todays date '2009/03/18' |'

however if i run this code on windows server 2003 sp2 or windows server 2003 r2, i receive a msgbox with the contents;

' | date account expires '2009/03/19' | one day before '0' | one week before '0' | todays date '2009/03/18' |'

looks like a bug to me, but i could be wrong...could someone shed some light on this

james

  • Developers
Posted (edited)

Tested it on a Win2k3 sp2 system and it worked fine for me.

What version AutoIt3 are you testing with?

What is the @error returned for the 2 _DateAdd() funcs?

you can test with this script:#include<date.au3>

$expirydate = '2009/03/19'
;now that date is in format YYYY/MM/DD, calculate 1d before, 1w before
$onedaybefore = _DateAdd('d', -1, $expirydate)
MsgBox(262144,'Debug line ~' & @ScriptLineNumber,'Selection:' & @lf & '$onedaybefore' & @lf & @lf & 'Return:' & @lf & $onedaybefore & @lf & @lf & '@Error:' & @lf & @Error);### Debug MSGBOX
$oneweekbefore = _DateAdd('w', -1, $expirydate)
MsgBox(262144,'Debug line ~' & @ScriptLineNumber,'Selection:' & @lf & '$oneweekbefore' & @lf & @lf & 'Return:' & @lf & $oneweekbefore & @lf & @lf & '@Error:' & @lf & @Error);### Debug MSGBOX
$todaysdate = StringLeft(_NowCalc(), 10)
MsgBox("", "", "| date account expires '" & $expirydate & "' | one day before '" & $onedaybefore & "' | one week before '" & $oneweekbefore & "' | todays date '" & $todaysdate & "' | ")

Jos

Edited by Jos

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.
  :)

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
×
×
  • Create New...