unlang time / date comparison

Franks Andy (RLZ) IT Systems Engineer Andy.Franks at sath.nhs.uk
Wed Sep 19 09:50:54 CEST 2012

Thanks Arran,
  I'll give it a try. I did find something to do with %1 / %I (can't
remember which) and dividing by "epoch" so may be able to use that too?
If in doubt give it a go eh?

-----Original Message-----
freeradius-users-bounces+andy.franks=sath.nhs.uk at lists.freeradius.org
[mailto:freeradius-users-bounces+andy.franks=sath.nhs.uk at lists.freeradiu
s.org] On Behalf Of Arran Cudbard-Bell
Sent: 18 September 2012 23:05
To: FreeRadius users mailing list
Subject: Re: unlang time / date comparison

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

List info/subscribe/unsubscribe? See

More information about the Freeradius-Users mailing list