mysql 查询前一周,一个月的数据 unix时间

end = datetime.date.today()
start = datetime.date.today() - relativedelta(months=+1)
 sql = f''' select user_id,duration,subject_1,item_id,channel,from_unixtime(create_time) as create_time from `t_exer_record_{i}` where from_unixtime(create_time) between '{start}'  and '{end}' 
 '''
          
now = datetime.datetime.now()
end = now.date()
start = end - datetime.timedelta(days=7)

sql = f'''
                          select user_id,duration,subject_1,item_id,channel,from_unixtime(create_time) as create_time from `t_exer_record_{i}` where from_unixtime(create_time) between '{start}'  and '{end} ' 

'''

猜你喜欢

转载自blog.csdn.net/weixin_40161254/article/details/84328370