如何获得当月的天数?
来源:互联网 发布:网络棋牌害死人 编辑:程序博客网 时间:2024/06/06 02:17
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
DECLARE@monthint,@yearint
SELECT@month=6,@year=2004
SELECTDATEPART(dd,DATEADD(m,1,CAST(STR(@month)+'/01/'+STR(@year)as
datetime))-1)
--方法二
DECLARE@DATEDATETIME
SET@DATE=GETDATE()
SELECTCAST(
--Firstdayofnextmonth
DATEADD(MONTH,DATEDIFF(MONTH,0,@DATE)+1,0)
-
--Firstdayofcurrentmonth
DATEADD(MONTH,DATEDIFF(MONTH,0,@DATE),0)
ASINT)
--方法三
这个你也可以写一个UDF来实现:
createfunctionfn_NumOfDaysInMon(@datedatetime)
returnsint
as
begin
declare@begmonthdatetime,@endmonthdatetime,@daysint
select@begmonth=dateadd(month,datediff(month,0,@date),0)
select@endmonth=dateadd(dd,-datepart(dd,@date),dateadd(mm,1,@date))
select@days=datediff(dd,@begmonth,@endmonth)+1
return@days
end
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
--方法一DECLARE@monthint,@yearint
SELECT@month=6,@year=2004
SELECTDATEPART(dd,DATEADD(m,1,CAST(STR(@month)+'/01/'+STR(@year)as
datetime))-1)
--方法二
DECLARE@DATEDATETIME
SET@DATE=GETDATE()
SELECTCAST(
--Firstdayofnextmonth
DATEADD(MONTH,DATEDIFF(MONTH,0,@DATE)+1,0)
-
--Firstdayofcurrentmonth
DATEADD(MONTH,DATEDIFF(MONTH,0,@DATE),0)
ASINT)
--方法三
这个你也可以写一个UDF来实现:
createfunctionfn_NumOfDaysInMon(@datedatetime)
returnsint
as
begin
declare@begmonthdatetime,@endmonthdatetime,@daysint
select@begmonth=dateadd(month,datediff(month,0,@date),0)
select@endmonth=dateadd(dd,-datepart(dd,@date),dateadd(mm,1,@date))
select@days=datediff(dd,@begmonth,@endmonth)+1
return@days
end
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
- 如何获得当月的天数?
- 如何获得当月的天数?
- 获得当月天数的Sql语句
- Sql语句获得当月天数
- 计算当月的天数
- 获取当月的天数。
- JS获得当月的天数和得到当月最后一天的日期
- JS根据年月实现获得当月天数
- 获取当月天数的方法
- java中 如何获取当月的天数、指定日期的月份天数
- 如何获得某个日期当月的最后一天
- 找出当月天数的两种方法
- 根据年份、月份取当月的天数
- JavaScript中获取当月的所有天数
- jquery获取当年月天数以及当月的最后一天|当月的天数
- 获取当月天数当月星期天数
- (转)如何获得两个日期相减的天数?
- oracle取当年天数与当月天数及指定月的天数
- 如何解决装完SP2之后,clienst端无法连接Sqlserver?
- T-SQL存储过程创建PDF格式文件(报表)
- 关于sharedpool的深入探讨(五)
- MDX中使用成员属性
- 导入导出数据语句小结
- 如何获得当月的天数?
- 如何把"用户定义的数据类型"的ower改为dbo?
- MDX中轴的使用
- UsebonnietoTestsystemIOspeed
- select返回记录的顺序
- Heapsofdata:tableswithoutclusteredindexes
- dbms_space.free_space
- 用SQLServer实现数据表中,将任意一条记录信息移动到该表中的任意位置
- 应用开发(一)