如何在asp.net中的两个日期之间获取记录 [英] how to get records between two dates in asp.net

查看:53
本文介绍了如何在asp.net中的两个日期之间获取记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI,



我希望在两个日期之间过滤数据...在我的数据库表中,我有Invoice_Date列。

我希望过滤日期,在数据库中它存储日期为'2013-10-06 00:00:00.000'。



可以任何人帮我解决这个问题



i want filter data between two dates... In my database table i have Invoice_Date column.
I want filter datewise and in database it is storing date as '2013-10-06 00:00:00.000'.

Can anyone help me to solve this

推荐答案

试试这个:

Try this:
SELECT * FROM TableName1 WHERE MyDate BETWEEN '2011/02/25' AND '2011/02/27'
--or
SELECT * FROM TableName1 WHERE MyDate BETWEEN Date1 AND Date2
--Date1 and Date2 are two DateTimes



或者可以使用:


or can use:

SELECT Date,TotalAllowance FROM Calculation WHERE MyDate >'2011/02/25' AND MyDate  <'2011/02/27'
--or
SELECT Date,TotalAllowance FROM Calculation WHERE MyDate > Date1 AND MyDate  < Date2
--Date1 and Date2 are two DateTimes







- Amit


select * from tableName where Invoice_Date between '2013-05-29 00:00:00.000' and '2013-05-30 00:00:00.000'


您始终可以使用Compare [ ^ ]方法。

您还可以使用 TimeSpan 类过滤o数据。



但是,它总是建议尽可能对数据库进行过滤。
You can always do this on the front end using the Compare[^] method.
You can also use TimeSpan class to filter out data.

However, its always recommended to do filtering on the database as far as possible.


这篇关于如何在asp.net中的两个日期之间获取记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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