• Sql获取时间


    def search_createtime_case_sql(mobile):
    # 昨日 今日 上周 本周 上个月 -- 本月 去年 本年 过去7天 过去30天
    sql_val = []
    sql_val.append(
    f"SELECT count(*) as num from t_case where doctorid = (select userGUID from t_dx_user where mobile = '{mobile}') and DataStatus = 1 and DATEDIFF(createtime,NOW())=-1 ")
    sql_val.append(
    f"SELECT count(*) as num from t_case where doctorid = (select userGUID from t_dx_user where mobile = '{mobile}') and DataStatus = 1 and DATEDIFF(updatetime,NOW())=0")
    sql_val.append(
    f"SELECT count(*) as num from t_case where doctorid = (select userGUID from t_dx_user where mobile = '{mobile}') and DataStatus = 1 and YEARWEEK(date_format(createtime,'%Y-%m-%d'),1) = YEARWEEK(now(),1)-1")
    sql_val.append(
    f"SELECT count(*) as num from t_case where doctorid = (select userGUID from t_dx_user where mobile = '{mobile}') and DataStatus = 1 and YEARWEEK(date_format(createtime,'%Y-%m-%d'),1) = YEARWEEK(now(),1)")
    sql_val.append(
    f"SELECT count(*) as num from t_case where doctorid = (select userGUID from t_dx_user where mobile = '{mobile}') and DataStatus = 1 and date_format(createtime,'%Y-%m')=date_format(DATE_SUB(curdate(), INTERVAL 1 MONTH),'%Y-%m')")
    sql_val.append(
    f"SELECT count(*) as num from t_case where doctorid = (select userGUID from t_dx_user where mobile = '{mobile}') and DataStatus = 1 and date_format(createtime,'%Y-%m')=date_format(now(),'%Y-%m')")
    sql_val.append(
    f"SELECT count(*) as num from t_case where doctorid = (select userGUID from t_dx_user where mobile = '{mobile}') and DataStatus = 1 and year(createtime)=year(date_sub(now(),interval 1 year))")
    sql_val.append(
    f"SELECT count(*) as num from t_case where doctorid = (select userGUID from t_dx_user where mobile = '{mobile}') and DataStatus = 1 and YEAR(createtime)=YEAR(NOW())")
    sql_val.append(
    f"SELECT count(*) as num from t_case where doctorid = (select userGUID from t_dx_user where mobile = '{mobile}') and DataStatus = 1 and DATEDIFF(createtime,NOW())<0 AND DATEDIFF(createtime,NOW())>-7")
    sql_val.append(
    f"SELECT count(*) as num from t_case where doctorid = (select userGUID from t_dx_user where mobile = '{mobile}') and DataStatus = 1 and DATEDIFF(createtime,NOW())<0 AND DATEDIFF(createtime,NOW())>-30")
    return sql_val
  • 相关阅读:
    尝试实现一个简单的C语言string类型
    LeetCode.49
    Python学习 —— 实现简单的爬虫
    图表可视化表达的逻辑原理
    颜色参数
    Python交互图表可视化Bokeh:7. 工具栏
    Python交互图表可视化Bokeh:6. 轴线| 浮动| 多图表
    Python交互图表可视化Bokeh:5 柱状图| 堆叠图| 直方图
    Python交互图表可视化Bokeh:4. 折线图| 面积图
    Python交互图表可视化Bokeh:3. 散点图
  • 原文地址:https://www.cnblogs.com/bufangyyyyy/p/13446921.html
Copyright © 2020-2023  润新知