在两个日期之间搜索数据 [英] searching data between two dates

查看:75
本文介绍了在两个日期之间搜索数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个数据库,可以根据日期向其中插入数据.
现在,我想根据日期搜索并显示我的数据.例如,我要显示插入的两个日期之间的数据.
我该怎么写?
在此先感谢.

解决方案

我假设您正在谈论SQL查询,如果是的话,请访问链接,
获取两个日期范围之间的记录 [ DECLARE @ DateA DATETIME @ DateB DATETIME SET @ DateA = - 任何内容 SET @ DateA = - 任何内容 选择 * FROM DummyTable 位置 DATEDIFF(DAY, @ DateA @ DateB )> = 0


选择两个指定日期之间的所有内容

 选择 * 来自 TableName 其中 MyDateTimeColumn  BETWEEN (GETDATE() and (GETDATE()-3) 


Hi All,

I have a database that i insert data into it according to date.
Now i want to search and display my data acording to the date. for example ,i want to show the datas which are between two date that they had inserted.
How can i write it?
Thanks in Advance.

I am assuming you are talking about SQL query, if so then please visit the link,
Fetching records between two date ranges [^]

Hope it helps to solve your problem.


something like this:

DECLARE @DateA DATETIME, @DateB DATETIME
SET @DateA = --whatever
SET @DateA = --whatever
SELECT * FROM DummyTable WHERE
DATEDIFF(DAY, @DateA, @DateB) >= 0


Selects everything bewteen the two specified dates

select * from TableName where MyDateTimeColumn BETWEEN (GETDATE() and (GETDATE()-3)


这篇关于在两个日期之间搜索数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆