keilamym Posted May 18, 2006 Share Posted May 18, 2006 i need just a little assistance. when i do a datediff calculation to a variable, can i use the datdif value in an "if then" statement. example. i want to pull the date of a file and put it into a variable use the datedif and date datecalc funtions to calculate what the date was 5 days ago. using the IF statement, compare the two dates and if the file date is older than the datecalc value by 5 days, then i want to run a command on the workstation. since the date format is yyyy,mm,dd, i'm not sure if autoit will calculate the dates correctly. any assistance would be appreciated. Keilamym Link to comment Share on other sites More sharing options...
Developers Jos Posted May 18, 2006 Developers Share Posted May 18, 2006 (edited) i need just a little assistance. when i do a datediff calculation to a variable, can i use the datdif value in an "if then" statement. example. i want to pull the date of a file and put it into a variable use the datedif and date datecalc funtions to calculate what the date was 5 days ago. using the IF statement, compare the two dates and if the file date is older than the datecalc value by 5 days, then i want to run a command on the workstation. since the date format is yyyy,mm,dd, i'm not sure if autoit will calculate the dates correctly. any assistance would be appreciated. Keilamym _DateDiff()/_DateAdd() can handle the input format: "yyyy/mm/dd[ hh:mm[:ss]]" or "yyyy/mm/dd[Thh:mm[:ss]]" "yyyy-mm-dd[ hh:mm[:ss]]" or "yyyy-mm-dd[Thh:mm[:ss]]" "yyyy.mm.dd[ hh:mm[:ss]]" or "yyyy.mm.dd[Thh:mm[:ss]]" If you want to know today-5 then you want to use _DateAdd("d",-5,_NowCalcDate()) Edited May 18, 2006 by JdeB 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 More sharing options...
keilamym Posted May 18, 2006 Author Share Posted May 18, 2006 _DateDiff() can handle the input format: "yyyy/mm/dd[ hh:mm[:ss]]" or "yyyy/mm/dd[Thh:mm[:ss]]" "yyyy-mm-dd[ hh:mm[:ss]]" or "yyyy-mm-dd[Thh:mm[:ss]]" "yyyy.mm.dd[ hh:mm[:ss]]" or "yyyy.mm.dd[Thh:mm[:ss]]" If you want to know today-5 then you want to use _DateAdd("d",-5,_NowCalcDate()) jdbe.. thanks.. i've complete the portion of the script that tells me what the a date - 5 days will be, but can the if then statement calculate the different. if the file date is more than 5 days older than todays date, then "do this" Thanks Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 18, 2006 Moderators Share Posted May 18, 2006 (edited) i need just a little assistance. when i do a datediff calculation to a variable, can i use the datdif value in an "if then" statement. example. i want to pull the date of a file and put it into a variable use the datedif and date datecalc funtions to calculate what the date was 5 days ago. using the IF statement, compare the two dates and if the file date is older than the datecalc value by 5 days, then i want to run a command on the workstation. since the date format is yyyy,mm,dd, i'm not sure if autoit will calculate the dates correctly. any assistance would be appreciated. KeilamymThis is how _DateDiff() with #include <date.au3> works:;=============================================================================== ; ; Description: Returns the difference between 2 dates, expressed in the type requested ; Parameter(s): $sType - returns the difference in: ; d = days ; m = Months ; y = Years ; w = Weeks ; h = Hours ; n = Minutes ; s = Seconds ; $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]" ; Requirement(s): None ; Return Value(s): On Success - Difference between the 2 dates ; On Failure - 0 and Set ; @ERROR to: 1 - Invalid $sType ; 2 - Invalid $sStartDate ; 3 - Invalid $sEndDate ; Author(s): Jos van der Zande ; Note(s): ; ;=============================================================================== Edit: ... man I was reading it and didn't bother to refresh to see if anyone had posted already... too slowwwww. Edited May 18, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Developers Jos Posted May 18, 2006 Developers Share Posted May 18, 2006 (edited) jdbe.. thanks.. i've complete the portion of the script that tells me what the a date - 5 days will be, but can the if then statement calculate the different. if the file date is more than 5 days older than todays date, then "do this" ThanksSomething like this? #include<date.au3> $n_tFile = "your file name" $n_Fdate = FileGetTime($n_tFile,1) $sdate=$n_Fdate[0] & "/" & $n_Fdate[1] & "/" & $n_Fdate[2] & " " & $n_Fdate[3] & ":" & $n_Fdate[4] & ":" & $n_Fdate[5] $edate=_NowCalc() If _DateDiff ('d',$sdate,$eDate) > 5 then ; EndIf Edited May 18, 2006 by JdeB 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 More sharing options...
keilamym Posted June 1, 2006 Author Share Posted June 1, 2006 (edited) Something like this? #include<date.au3> $n_tFile = "your file name" $n_Fdate = FileGetTime($n_tFile,1) $sdate=$n_Fdate[0] & "/" & $n_Fdate[1] & "/" & $n_Fdate[2] & " " & $n_Fdate[3] & ":" & $n_Fdate[4] & ":" & $n_Fdate[5] $edate=_NowCalc() If _DateDiff ('d',$sdate,$eDate) > 5 then ; EndIf thanks this worked perfectly.. i had to change the paramerters to look for the last accessed date... thanks again. Edited June 1, 2006 by keilamym Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now