SSRS、SQLserver日期参数初始化

1、本月第一天
=DateSerial(YEAR(Today()), MONTH(Today()), 1)
2、本月最后一天
=DateAdd(“d”,-1,(DateAdd(“m”, 1, DateSerial(Year(Today()), Month(Today()), 1))))
3、上月第一天
=DateAdd(“m”, -1, DateSerial(Year(Today()), Month(Today()), 1))
4、上月最后一天
=DateAdd(“d”, -1, DateSerial(Year(Today()), Month(Today()), 1))
5、下月第一天
=DateAdd(“m”, 1, DateSerial(Year(Today()), Month(Today()), 1))
6、下月最后一天
=DateAdd(“d”,-1,(DateAdd(“m”, 2, DateSerial(Year(Today()), Month(Today()), 1))))
7、本年第一天
=DateSerial(YEAR(Today()), 1, 1)
8、本年最后一天
=DateSerial(YEAR(Today()), 12, 31)
9、去年第一天
=DateAdd(“yy”, -1, DateSerial(YEAR(Today()), 1, 1))
10、去年最后一天
=DateAdd(“d”, -1, DateSerial(YEAR(Today()), 1, 1))


1.SSRS得到某一天本周的周一
=DateAdd("d", -(WeekDay(Parameters!From.Value,FirstDayOfWeek.Monday))+1, Parameters!From.Value)
2.SSRS得到某一天下周的周一
=DateAdd("d", 8-WeekDay(Parameters!From.Value,FirstDayOfWeek.Monday), Parameters!From.Value)
3.SSRS得到某个月的第一天
=DateSerial(YEAR(TODAY), MONTH(TODAY), 1)
4.SSRS得到某个年的第一天
=DateSerial(YEAR(TODAY), 1, 1)
5.SSRS得到去年的第一天
=DateSerial(YEAR(TODAY)-1, 1, 1)


Date FormatVB Functions.Net Functions
First Date of last month=DateAdd(“m”, -1, DateSerial(Year(Now()), Month(Now()), 1))=Today.AddDays(1- Today.Day).AddMonths(-1)
Last date of last month=DateAdd(“d”, -1, DateSerial(Year(Now()), Month(Now()), 1))=Today.AddDays(-1.0 * Today.Day)
First date of current month=DateSerial(Year(Now()), Month(Now()), 1)=Today.AddDays(1 – Today.Day)
Last date of current month=DateAdd(“d”,-1,(DateAdd(“m”, 1, DateSerial(Year(Now()), Month(Now()), 1))))=Today.AddDays(-1 * Today.Day).AddMonths(1)
Yesterday’s date=DateAdd(“d”, -1, Today)=Today.AddDays(-1)
Tomorrow’s date=DateAdd(“d”, 1, Today)=Today.AddDays(1)
First day of current year=DateSerial(Year(Now()), 1, 1)=Today.AddDays(1- Today.DayOfYear)
Last day of current year=DateSerial(Year(Now()), 12, 31)=Today.AddDays(-1 * Today.DayOfYear).AddYears(1)
Last day of current year=DateSerial(Year(Now()), 12, 31)=Today.AddDays(-1 * Today.DayOfYear).AddYears(1)

以下是SQL语句,和SSRS有区别:
本年第一天
DateAdd(yy,DateDiff(yy,0,getdate()),0)
本季度第一天
dateAdd(qq,DateDiff(qq,0,getdate()),0)
本月的第一天
DateAdd(mm,DateDiff(mm,0,getdate()),0)
本周的第一天
DateAdd(wk,DateDiff(wk,0,getdate()),0)

转自:https://blog.csdn.net/zengcong2013/article/details/50130199

    Danzel
    Danzel管理员

    • 声明:本文由Danzel于2022-01-12转载(优化),转载须经原站同意并注明出处。
    • 本文地址:http://maryd.cn/?id=213
    上一篇:Dynamics ax version
    下一篇:SQLserver日期相关获取及解析

    留言评论

    暂无留言
    取消
    扫码支持