unlang time / date comparison
Arran Cudbard-Bell
a.cudbardb at freeradius.org
Wed Sep 19 00:04:36 CEST 2012
On 18 Sep 2012, at 22:38, "Franks Andy \(RLZ\) IT Systems Engineer" <Andy.Franks at 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
More information about the Freeradius-Users
mailing list