Jump to content

_DateDiff help


 Share

Recommended Posts

What you have should work fine, assuming your date ($t) is in the correct format.

_NowCalcDate() would also likely be more appropriate than _NowCalc()

#include <Date.au3>

$t = "2010/08/11"
$diff = _DateDiff('D', $t, _NowCalcDate())
MsgBox(0,"", $diff)

If _DateDiff('D', $t, _NowCalcDate()) < 30 Then Beep(800,100)
Edited by Spiff59
Link to comment
Share on other sites

i tryed my code but its not working

$t = FileGetTime($m_dir & '\' & $event_value, 1)

If _DateDiff( 'D', $t,_NowCalc()) <30 Then

Stick a "Msgbox(0,"",$t)" in there. What does it display?

I'm guessing it's not a valid date in the format of YYYY/MM/DD.

Edit: I might suggest dropping the "1" parameter from the FileGetTime() call and then add the following line:

$t = $t[0] & "\" & $t[1] & "\" & $t[2]

Test what comes out of that with a temporary Msgbox() statement.

Edited by Spiff59
Link to comment
Share on other sites

FileGetTime returns a string in the format of YYYYMMDDHHMMSS, whereas _DateDiff is looking for a string in the format of "YYYY/MM/DD[ HH:MM:SS]" for the start and end dates, as you can see, they are not in the same format, so it will never work using those two functions together as is. You will need to reformat your FileGetTime returned result to match the format that _DateDiff requires. You could use a StringMid on $t and split them into the yyyy mm dd hh mm ss components, and then concantenate a string with those values $String = $YYYY & "/" & $mm & "/" & $dd ...

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

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