Changing the format of a date attribute

Patric patricrt at gmail.com
Tue Dec 8 10:34:16 CET 2009


Hi everyone,

Firstly, thanks Alan for your help with my acct_start_time problem, that 
was exactly what I was after. The only problem that remains for me is 
getting the value into a different format so I can store it in my 
database table.

So I have the following setup currently:

share/dictionary.freeradius:

ATTRIBUTE	FreeRADIUS-Acct-Session-Start-Time	2	date


Then in my preacct section:

   update request {
       FreeRADIUS-Acct-Session-Start-Time = "%{expr: %l - 
%{%{Acct-Session-Time}:-0} - %{%{Acct-Delay-Time}:-0}}"
   }


Then I can use %{FreeRADIUS-Acct-Session-Start-Time} which is in the 
date format:

"Dec  8 2009 09:14:14 GMT".


The database field I will be writing into is a MySQL DateTime field, 
which is in the format "YYYY-MM-DD HH:ii:ss", eg:

"2009-12-08 11:27:34"


Is there any way for me to get my FreeRADIUS-Acct-Session-Start-Time 
attribute value into that date format?

Any advice would be very much appreciated.
Many thanks,
Patric



More information about the Freeradius-Users mailing list