当前位置:网站首页>SQL 根据时间范围查询数据
SQL 根据时间范围查询数据
2022-07-30 11:30:00 【※※冰馨※※】
今天的所有数据:select * from 表名 where DateDiff(day,datetime字段,getdate())=0
昨天的所有数据:select * from 表名 where DateDiff(day,datetime字段,getdate())=1
7天内的所有数据:select * from 表名 where DateDiff(day,datetime字段,getdate())<=7
30天内的所有数据:select * from 表名 where DateDiff(day,datetime字段,getdate())<=30
本月的所有数据:select * from 表名 where DateDiff(mm,datetime字段,getdate())=0
本年的所有数据:select * from 表名 where DateDiff(yy,datetime字段,getdate())=0
注:DateDiff 前可以添加过滤条件
边栏推荐
- Introduction to IoT Technologies: Chapter 6
- TensorFlow自定义训练函数
- Kubernetes 入门实战03 中级篇
- [Cloud-Building Co-creation] Huawei Cloud and Hongmeng collaborate to cultivate innovative developers
- Meituan internal push + school recruitment written test + summary of knowledge points
- Apifox 生成接口文档 教程与操作步骤
- stm32 RTC闹钟唤醒低功耗模式
- 深入浅出零钱兑换问题——背包问题的套壳
- 自定义查询--关于倒排索引的研究
- Transfer Learning技术研修
猜你喜欢

API 网关 APISIX 在Google Cloud T2A 和 T2D 的性能测试

嵌入式环境下并发控制与线程安全

【JZ64 求1+2+3+...+n】

Summary of text alignment, line height, space, etc.

MySQL——数据库基础

基于MySQL数据库,Redis缓存,MQ消息中间件,ES搜索引擎的高可用方案解析

限时招募!淘宝无货源副业,800/天,不限经验,男女皆可,仅限前200名!

Interviewer: Redis bloom filter and the cuckoo in the filter, how much do you know?

【ASP.NET Core】选项类的依赖注入

HJY-F931A/YJ三相电压继电器
随机推荐
嵌入式环境下并发控制与线程安全
Verilog grammar basics HDL Bits training 08
ansible学习笔记01
重写并自定义依赖的原生的Bean方法
decodeURIComponent()、eval()、encodeURIComponent()
LeetCode_236_二叉树的最近公共祖先
mapbox-gl开发教程(十四):画圆技巧
英 文 换 行
Apifox 生成接口文档 教程与操作步骤
Niuke-TOP101-BM42
《跟唐老师学习云网络》 - 问题定位 - 主机通但容器不通
Interviewer: Redis bloom filter and the cuckoo in the filter, how much do you know?
概率论的学习和整理7:理解期望和方差还是要回到随机试验本身,期望不是平均值,方差的公式不同情况不同
基于多目标两阶段随机规划方法的电热联合系统调度
Jingdong school recruited written test questions + summary of knowledge points
Redis master-slave replication
ORA-00600 [13013], [5001], [268] 问题分析及恢复
云原生应用的概念和云原生应用的 15 个特征
Verilog grammar basics HDL Bits training 07
深入浅出零钱兑换问题——背包问题的套壳