当前位置:网站首页>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 前可以添加过滤条件
边栏推荐
- Typroa 替代工具marktext
- 2022-07-29 Gu Yujia Study Notes Exception Handling
- LeetCode_236_二叉树的最近公共祖先
- Current relay JL-8GB/11/AC220V
- Get the original data API on 1688app
- 单片机开发之静态LED显示
- Introduction to IoT Technologies: Chapter 6
- 横向对比5种常用的注册中心,无论是用于面试还是技术选型,都非常有帮助
- Interviewer: Redis bloom filter and the cuckoo in the filter, how much do you know?
- 汇编实现冒泡排序
猜你喜欢

向上管理读书笔记

Explain the problem of change exchange in simple terms - the shell of the backpack problem

STM32F1读取MLX90632非接触式红外温度传感器

电流继电器JL-8GB/11/AC220V

Introduction to IoT Technologies: Chapter 6

Program environment and preprocessing (detailed)

High energy output!Tencent's internal MyCat middleware manual, both theoretical and practical

电压继电器HDY-A/1-220VAC-1

Verilog语法基础HDL Bits训练 07

GBJ2510-ASEMI电机专用25A整流桥GBJ2510
随机推荐
ORA-00600 [13013], [5001], [268] 问题分析及恢复
基于MySQL数据库,Redis缓存,MQ消息中间件,ES搜索引擎的高可用方案解析
横向对比5种常用的注册中心,无论是用于面试还是技术选型,都非常有帮助
2022-07-29 Gu Yujia Study Notes Exception Handling
Reverse linked list - iterative inversion method
概率论得学习和整理6:概率的分布
域名怎么注册备案解析?
decodeURIComponent()、eval()、encodeURIComponent()
LeetCode_235_二叉搜索树的最近公共祖先
Taobao/Tmall taobao comments q&a list interface API
重写并自定义依赖的原生的Bean方法
spin lock和mutex使用场景的差异
idea的package没有空心
Matlab基础(4)——矩阵
Redis master-slave replication
win下怎么搭建php环境的方法教程
【ASP.NET Core】选项类的依赖注入
干货|语义网、Web3.0、Web3、元宇宙这些概念还傻傻分不清楚?(中)
Difference between C# enumeration type and xaml
Flexible distribution parameters of mechanical system modeling and control of research and development