关于日期,月份和年份功能 [英] about date,month and year function

查看:122
本文介绍了关于日期,月份和年份功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从asp.net中归档的数据库中选择不同的月份?我使用Access数据库.

how to select distinct month from database filed in asp.net? i use access database.

推荐答案

SELECT DISTINCT MONTH(Date1) FROM Table1


但是,此查询会将2010年1月和2011年1月视为相同,为区别起见,还必须包括年份.


However, this query will treat Jan 2010 and Jan 2011 as one and the same, to differentiate this, you have to include year also.

SELECT DISTINCT YEAR(Date1), MONTH(Date1) FROM Table1


下面的链接将向您显示选择DatePart
http://www.techonthenet.com/access/functions/date/datepart.php [ ^ ]

以下链接将向您展示如何编写不同的查询.
http://blogs.office.com/b/microsoft-access/archive/2007/09/19/writing-a-count-distinct-query-in-access.aspx [
The following link will show you to select DatePart
http://www.techonthenet.com/access/functions/date/datepart.php[^]

And the following link will show you how to write distinct query.
http://blogs.office.com/b/microsoft-access/archive/2007/09/19/writing-a-count-distinct-query-in-access.aspx[^]

Combined the two links and set where condition with month and year. I can write the query for you but you should learn to write.


我有示例查询以获取不同的月份:
I have sample query for to get distinct month :
Select Distinct datepart(month,yourDate) as Month, datepart(year,yourDate) as Year from TableName



希望对您有所帮助,
Theingi Win



Hope be helpful,
Theingi Win


这篇关于关于日期,月份和年份功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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