Changing the format of a date attribute

Patric patricrt at gmail.com
Wed Dec 9 11:37:18 CET 2009


Hi again all :)

Patric wrote:
> Alan DeKok wrote:
>> Patric wrote:
>>> Is there any way for me to get my FreeRADIUS-Acct-Session-Start-Time
>>> attribute value into that date format?
>>
>> http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_from-unixtime 
>>
> So now I have the following:
> 
> STR_TO_DATE('%{FreeRADIUS-Acct-Session-Start-Time}', '%M %d %Y %H:%i:%s'))
> 
> And that converts "Dec  8 2009 09:14:14 GMT" into "2009-12-08 09:14:14"

I have a curious problem trying to format the date field in my MySQL 
statement as shown above.

In my sql/mysql/dialup.conf I have the following:

accounting_start_query_alt = "UPDATE ${acct_table_new} \
SET \
acct_start_time = STR_TO_DATE('%{FreeRADIUS-Acct-Session-Start-Time}', 
'%M %d %Y %H:%i:%s'), \
...


The problem with the above is that some of those formatting options ('%M 
%d %Y %H:%i:%s') are also defined as one-character variables, so instead 
of formatting the date with those options, its replacing each with the 
variable value, and when Im trying to end up with:

2009-12-08 09:14:14

instead Im ending up with:

2009-12-09 11:0126538264:AutoShapedVC


As you can see the minutes were replaced with the Calling Station ID and 
the seconds were replaced with the Connect-Info...

Is there any way for me to perhaps escape my format string, or some 
other work-around?

Many thanks
Patric



More information about the Freeradius-Users mailing list