当前位置:网站首页>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 前可以添加过滤条件
边栏推荐
- Niuke-TOP101-BM42
- LeetCode_235_二叉搜索树的最近公共祖先
- Bagging-Blending Multi-Model Fusion Short-Term Electricity Load Forecasting Based on Weighted Grey Correlation Projection
- Manage reading notes upward
- 周鸿祎:微软抄袭了360安全模式 所以成为美国最大的安全公司
- 概率论的学习和整理--番外4: 关于各种平均数:算术平均数,几何平均数,调和平均数,以及加权平均数和平方平均数 (未完成)
- 2022-07-29 Gu Yujia Study Notes Exception Handling
- STM32F1 reads MLX90632 non-contact infrared temperature sensor
- TensorFlow自定义训练函数
- Explain the problem of change exchange in simple terms - the shell of the backpack problem
猜你喜欢

Typroa alternative tool marktext

Verilog grammar basics HDL Bits training 08

Microsoft SQL server hacked, bandwidth stolen

Beyond Stream Processing!The 4th real-time computing Flink challenge is launched, and 490,000 prizes are waiting for you!

时间序列曲线相似性

VSCode更改插件的安装位置

RY-D1/1 Voltage Relay

I built another wheel: GrpcGateway

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

MySQL——数据库基础
随机推荐
PanGu-Coder: Function-level code generation model
English line break
contentDocument contentWindow,canvas 、svg,iframe
stm32 RTC闹钟唤醒低功耗模式
Program environment and preprocessing (detailed)
Leetcode 125. 验证回文串
Verilog语法基础HDL Bits训练 07
基于滑模控制的不确定中立型系统有限时间稳定
Horizontal comparison of 5 commonly used registration centers, whether it is used for interviews or technical selection, is very helpful
idea的package没有空心
Bagging-Blending Multi-Model Fusion Short-Term Electricity Load Forecasting Based on Weighted Grey Correlation Projection
Matlab基础(5)——符号运算
高能产出!腾讯内部的MyCat中间件手册,理论实操齐下
Detailed explanation of @RequestBody and @ResponseBody
Verilog grammar basics HDL Bits training 07
Voltage relay HDY - vac - 1 A / 1-220
程序环境和预处理(详解)
深入浅出零钱兑换问题——背包问题的套壳
淘宝/天猫淘宝评论问答列表接口 API
ADC0808/9 signal acquisition developed by single chip microcomputer