Selecting date formats for aggregate calculations from database with Django

后端 未结 1 1945
暖寄归人
暖寄归人 2021-01-14 09:07

I would like to do aggregate calculations based on month for a datetime field.

I am currently using the extra() function to format the date like:

...         


        
相关标签:
1条回答
  • 2021-01-14 09:45

    Run the following in your MySQL database, to create a forwarding function.

    delimiter //
    
    create function strftime ( d date, format varchar(255) )   
       RETURNS varchar(64)
       LANGUAGE SQL
       DETERMINISTIC
       COMMENT 'synonym for date_format'
       return date_format(d, format) ;
    //
    delimiter ;
    
    0 讨论(0)
提交回复
热议问题