开发者

How can I append a default time value to a datetime parameter?

开发者 https://www.devze.com 2023-03-22 13:34 出处:网络
In reporting services, I have a \"from\" and \"to\" field to de开发者_运维技巧note datetimes that the report is to run on. The problem is that the default datetime picker picks a default time of 12:00

In reporting services, I have a "from" and "to" field to de开发者_运维技巧note datetimes that the report is to run on. The problem is that the default datetime picker picks a default time of 12:00am for the time, I want the "from" field to be date + "00:00" and the "to" field to be date + "23:59:59" How can I do this?


The field referencing the parameters with "Expression" property on the field will have syntax similar to the following:

=Parameters!From.Value

and

=Parameters!To.Value

The expressions should be modified as follows: from:

=FORMAT(Parameters!From.Value, "MM/dd/yyyy HH:mm:ss")

and to:

=FORMAT(DATEADD(,SECOND,-1,DATEADD(DAY,1,CDATE(Parameters!To.Value))),"MM/dd/yyyy HH:mm:ss")

If my syntax is off, you can verify what I am doing at the following pages:

http://msdn.microsoft.com/en-us/library/aa337194%28v=SQL.100%29.aspx

http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx

Thanks. Let me know if you need anything else.

UPDATE:

You'll want to apply the following to your "To" date parameter to whatever data retrieval call you are supplying parameters to if you want the date to go through the "To" date (same syntax as above):

=DATEADD(,SECOND,-1,DATEADD(DAY,1,CDATE(Parameters!To.Value)))

Frank


Use this

    =DateAdd("s",-1,DateAdd("d",1,Parameters!dateTo.Value))

this format works. when using ',second' as Frank did it errored even removing the ','

0

精彩评论

暂无评论...
验证码 换一张
取 消