zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    Sql Server数据库快照初探
    RestTemplate的exchange()方法,解决put和delete请求拿不到返回值的问题
    常用 HTTP 状态码
    RestTemplate进行访问分页PageInfo
    Java RestTemplate传递参数
    SQL-----数据库三种删除方式详解
    Mybatis异常-java.lang.IllegalArgumentException: invalid comparison:java.util.Date and java.lang.String
    SpringBoot 项目不加载 application.properties 配置文件
    git设置、查看、取消代理
    Layui:select下拉框回显
  • 原文地址:https://www.cnblogs.com/bufangyyyyy/p/13446921.html
Copyright © 2011-2022 走看看