Jump to content

Date Expired Function ?


Recommended Posts

Hi,

for what? Parameter date and days and then return if expired?

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Hi,

for what? Parameter date and days and then return if expired?

So long,

Mega

i have a Date : "19/02/2007" & Time : "12:01:53"

i need to check against the PC clock to see if this Moment Has happend or is in the future.

EDIT : i found this but it doesnt work :? any1 knows why ?

If _DateDiff("s", IniRead2($i2, "Year") & "/" & IniRead2($i2, "Month") & "/" & IniRead2($i2, "Day") & "[" & IniRead2($i2, "Hour") & ":" & IniRead2($i2, "Minute") & ":00]", @YEAR & "/" & @MON & "/" & @MDAY & "[" & @HOUR & ":" & @MIN & ":" & @SEC & "]") > 0 Then Lunch()
Edited by DaProgrammer
Link to comment
Share on other sites

This should get you started

_NowCalc ( ) : Returns the current Date and Time in format YYYY/MM/DD HH:MM:SS

EDIT: You need to use the "#Include <Date.au3>"

ty, its easier this way.

now why does this doesnt work :

If _DateDiff( 's',$Input_Year & "/" & $Input_Month & "/" & $Input_Day & " " & $Input_Hour & ":" & $Input_Min & ":00",_NowCalc()) > 0 Then Return

this wont work either :

If _DateDiff( 's',String($Input_Year) & "/" & String($Input_Month) & "/" & String($Input_Day) & " " & String($Input_Hour) & ":" & String($Input_Min) & ":00",_NowCalc()) > 0 Then Return
Edited by DaProgrammer
Link to comment
Share on other sites

OK now it works when its clean program like this :

#include <Date.au3>
 $Input_Day = 15
 $Input_Hour = 12
 $Input_Min = 12
 $Input_Month = 06
 $Input_Year = 2006
 
 
 If _DateDiff( 's',String($Input_Year) & "/" & String($Input_Month) & "/" & String($Input_Day) & " " & String($Input_Hour) & ":" & String($Input_Min) & ":00",_NowCalc()) > 0 Then MsgBox(0,"",_NowCalc())

but inside Function it doesnt why ?

Func Save()
     If _DateDiff( 's',String($Input_Year) & "/" & String($Input_Month) & "/" & String($Input_Day) & " " & String($Input_Hour) & ":" & String($Input_Min) & ":00",_NowCalc()) > 0 Then Return
Link to comment
Share on other sites

  • Developers

OK now it works when its clean program like this :

#include <Date.au3>
 $Input_Day = 15
 $Input_Hour = 12
 $Input_Min = 12
 $Input_Month = 06
 $Input_Year = 2006
 
 
 If _DateDiff( 's',String($Input_Year) & "/" & String($Input_Month) & "/" & String($Input_Day) & " " & String($Input_Hour) & ":" & String($Input_Min) & ":00",_NowCalc()) > 0 Then MsgBox(0,"",_NowCalc())

but inside Function it doesnt why ?

Func Save()
     If _DateDiff( 's',String($Input_Year) & "/" & String($Input_Month) & "/" & String($Input_Day) & " " & String($Input_Hour) & ":" & String($Input_Min) & ":00",_NowCalc()) > 0 Then Return
Just try to do some debugging when you are programming and it doesn't work as expected.

Put MsgBox() or ConsoleWrite statement in your code to check the exact content of variables ... (avoid this guessing game) :whistle:

Also no need for the string() function in there ...

:lmao:

Edited 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

I made this a while back... does it suit your needs?

;You must #include <date.au3>
;Returns the age of a file in days
Func _FileAge($FilePathAndName)
    $iToday = _DateToDayValue (@YEAR, @MON, @MDAY)
    $iTime = FileGetTime($FilePathAndName,0,0)
    $iJulian = _DateToDayValue($iTime[0], $iTime[1], $iTime[2])
    $iAge = $iToday - $iJulian
    If $iAge < 0 Then $iAge = 0
    Return ($iAge)
EndFunc
Edited by SpookMeister

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Link to comment
Share on other sites

Hi,

or easy way:

#include<date.au3>
Global $date = "2006/02/19 12:01:53"

MsgBox(0,"",_checkDate($date))

Func _checkDate($date)
    If $date < _NowCalc() Then Return 1; past
    If $date = _NowCalc() Then Return 2
    If $date > _NowCalc() Then Return 3; future
EndFunc  ;==>_checkDate

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Hi,

or easy way:

#include<date.au3>
Global $date = "2006/02/19 12:01:53"

MsgBox(0,"",_checkDate($date))

Func _checkDate($date)
    If $date < _NowCalc() Then Return 1; past
    If $date = _NowCalc() Then Return 2
    If $date > _NowCalc() Then Return 3; future
EndFunc ;==>_checkDate

So long,

Mega

Good idea, but I would go with returns of 0, 1, and 2, which makes it easier to use with: If _checkDate() Then...

:whistle:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...