在 SQL Server 2005 中选择具有特定月份和年份的记录

发布于 2024-10-24 18:56:14 字数 146 浏览 5 评论 0原文

我想列出特定月份和年份的记录。表名称为“到达”,“日期”是存储添加记录的日期的字段。这是通过 C# 应用程序完成的。例如,如果用户在应用程序中选择月份为“4 月”,年份为“2009 年”,则会列出 2009 年 4 月添加的所有记录。 (我只需要查询,希望我能弄清楚其余的:))

I want to list records with a particular month and year. The table name is 'Arrival' and 'date' is the field that stores the date that the record was added. This is to be done from a C# application. For example, if the user selects month as 'April' and year as '2009' in the application, it will list all the records that were added on April,2009. (I only need the query, hope I can figure out the rest :) )

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情痴 2024-10-31 18:56:14

创建一个将月份和年份输入作为 int 的存储过程可能是最简单的。
身体会是这样的:

Select /*Column List */ 
from Arrival
where Month([Date]) = @Month 
and Year([Date]) = @Year

Probably easiest to create a stored procedure that takes Month and Year inputs as int.
The body would be something like this:

Select /*Column List */ 
from Arrival
where Month([Date]) = @Month 
and Year([Date]) = @Year
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文