unlang time / date comparison
Hi, Hopefully a simple question. I've looked around for a while but can't find the answer to this. I'd like to be able to take a date/time from a sql database, use unlang (not a module) to compare it to the current time and make a decision based on the fact that it's, for example, less or more than 3600 seconds/60 minutes/1 hour etc ago. I can't really work out the comparison of dates, or simple mathematical functions for that matter. Perhaps I'm missing something obvious - apologies if so, I've not been using FR for that long. Thanks as always. Andy
On 18 Sep 2012, at 22:38, "Franks Andy \(RLZ\) IT Systems Engineer" <Andy.Franks@sath.nhs.uk> wrote:
Hi,
Hopefully a simple question. I’ve looked around for a while but can’t find the answer to this.
I’d like to be able to take a date/time from a sql database, use unlang (not a module) to compare it to the current time and make a decision based on the fact that it’s, for example, less or more than 3600 seconds/60 minutes/1 hour etc ago.
Use one of the SQL functions (UNIX_TIMESTAMP()) to pull the date field value out as an integer and do a straight comparison with "%{l}". Or if you write a SQL timestamp string into a date type attribute, it might be smart enough to parse it for you, and then you can do "%{integer:Timestamp-Attr}" and compare with "%{l}". Not 100% sure the code is there to do that though... -Arran
Am 18.09.2012 23:38, schrieb Franks Andy (RLZ) IT Systems Engineer:
unlang time / date comparison
I'd like to be able to take a date/time from a sql database,use unlang (not a module) tocompare it to the current time and make a decision based on the fact that it's, for example,less or more than 3600 seconds/60 minutes/1 hour etc ago.
welcome in the club: http://freeradius.1045715.n5.nabble.com/account-activate-datetime-tp5715390.... greez, sky...
On 18 Sep 2012, at 23:05, SkyDiablo <skydiablo@gmx.net> wrote:
Am 18.09.2012 23:38, schrieb Franks Andy (RLZ) IT Systems Engineer:
I’d like to be able to take a date/time from a sql database, use unlang (not a module) to compare it to the current time and make a decision based on the fact that it’s, for example, less or more than 3600 seconds/60 minutes/1 hour etc ago.
welcome in the club: http://freeradius.1045715.n5.nabble.com/account-activate-datetime-tp5715390....
To answer your formatting question: https://github.com/alandekok/freeradius-server/blob/master/src/lib/valuepair... It's a case of RTFC :)
participants (3)
-
Arran Cudbard-Bell -
Franks Andy (RLZ) IT Systems Engineer -
SkyDiablo