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
  • 相关阅读:
    数据类型
    注释
    编译型语言和解释型语言
    POJ1026 Cipher(置换的幂运算)
    最短路(代码来源于kuangbin和百度)
    POJ1753 Flip Game(bfs、枚举)
    POJ1860 Currency Exchange(bellman-ford)
    【转】博弈—SG函数
    【转】欧几里得与扩展欧几里得
    HDU 5833 Zhu and 772002(高斯消元)
  • 原文地址:https://www.cnblogs.com/bufangyyyyy/p/13446921.html
Copyright © 2011-2022 走看看