Date Time Expression - SSRS‏

原创 2010年08月03日 11:22:00

 

Last week I received my friend's email, After discussion in the MSN, send to me mail,

 

What About Date Time Experssion - SSRS

 

As  following:

 

In our application year is considered to be divided into 4 quarters. Jan-March, April-Jun, Jul-Sep, Oct-Dec.

If I have selected my time range to be ‘Last Quarter’ and Current date is 2010/07/26. I should be able to get Start Date and End Date as 2010/04/01 and 2010/06/30 respectively. I wrote the following expressions to achieve this.

 

Last Quarter:

Start Date:  =cdate(year(dateadd("q",-1,today())) & "/" & month(dateadd("q",-1,today()))  & "/1"),

End Date:    =dateadd("d", -1, cdate(year(dateadd("q",-0,today())) & "/" & month(dateadd("q",-0,today()))  & "/1"))

 

If my current date is July it displays the start and end dates properly. However if my system date is in August it shows 2010/05/01 and 2010/07/31. This is because in RS the quarter stands for 3 months and it takes last 3 months dates.

 

How do I customize the date expression to consider the quarter separation as per our application requirement.

 

-Rashmi

 

 

My reply

 

This is a SSRS function of the problem, so you can Design your Expression,Reference this.

 

Last Quarter:
Start Date:  =Today().AddDays(1 - Today().Day).AddMonths(-(((Today().Month - 1) Mod 3) + 3))
End Date:  =Today().AddMonths(-(((Today().Month - 1) Mod 3) + 3)).AddDays(-Today().Day).AddMonths(3)

I test it, is ok for SSRS.

 

p.s. My Test environment

 

1、Windows Server 2008 R2

2、Sql Server 2008 R2

 

 

 

 

 

 

 

Time, Date and Timer in STEP 7

  • 2017年11月12日 09:07
  • 905KB
  • 下载

02_date_and_time.rar

  • 2013年09月29日 15:33
  • 42KB
  • 下载

数据库中关于datetime、date 、time数据类型比较,及插入日期时间数据格式

USE [DemoDataBase] GO /****** Object:  Table [dbo].[tb_Time]    Script Date: 11/21/2013 14:26:10 *...

boost-date-time-1.41.0-11.el6_1.2.i686.rpm

  • 2015年06月19日 21:43
  • 36KB
  • 下载

MFC控件(10): Date Time Picker-使用及日期运算

http://blog.csdn.net/weiwenhp/article/details/9404879 有些地方我们可能需要用户输入时间信息.MFC里面有个控件Date Time Pic...

%date%和%time%参数

  • 2011年02月09日 08:12
  • 501B
  • 下载

java中存储mysql数据库时间类型【date、time、datetime、timestamp】

mysql中时间类型,date、time、datetime、timestamp,java存储mysql中时间

自定义的 Date Time Picker 控件

  • 2010年10月16日 18:51
  • 470KB
  • 下载
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Date Time Expression - SSRS‏
举报原因:
原因补充:

(最多只允许输入30个字)