Wednesday, March 28, 2012

Report Parameter Date AND Time

SSRS2005.
In the Report Parameters dialog, I click Non-queried in the Default values
section, and use =Today(). I get today's date, which is exactly what I want.
But now I need to apply some formating, which generates an error:
=Format(Today(), "dd MMM yy hh:mm:ss")
How do I apply dd MMM yy hh:mm:ss formating to my Report Parameter without
any errors?
Thanks,
--
RandyTry going to properties of the text box and Format tab just give
dd-mm-yyyy-hh:mm:ss in the custom.
Amarnath
"randy1200" wrote:
> SSRS2005.
> In the Report Parameters dialog, I click Non-queried in the Default values
> section, and use =Today(). I get today's date, which is exactly what I want.
> But now I need to apply some formating, which generates an error:
> =Format(Today(), "dd MMM yy hh:mm:ss")
> How do I apply dd MMM yy hh:mm:ss formating to my Report Parameter without
> any errors?
> Thanks,
> --
> Randy|||The Today() property only gives you the date with time set to 00:00:00. You
should use the Now() property if you want time as well as date.
HTH,
Magendo_man
"randy1200" wrote:
> SSRS2005.
> In the Report Parameters dialog, I click Non-queried in the Default values
> section, and use =Today(). I get today's date, which is exactly what I want.
> But now I need to apply some formating, which generates an error:
> =Format(Today(), "dd MMM yy hh:mm:ss")
> How do I apply dd MMM yy hh:mm:ss formating to my Report Parameter without
> any errors?
> Thanks,
> --
> Randy|||Hello Randy,
Have you tried Amarnath's suggestion on use the "dd-MMM-yy hh:mm:ss" format
string instead to see whether it works. Based on my test, both the
followign formatting code work correctly:
=Format(Today(), "dd MMM yy hh:mm:ss")
=Format(Today(), "dd-MMM-yy hh:mm:ss")
Also, I suggest you consider the following options:
Currently you directly use the following expression for your report
parameter:
=Format(Today(), "dd MMM yy hh:mm:ss")
Then the paramter's type must be "string" , correct? Instead of directly
add the formatting operation in the parameter expression(and define the
parameter as string), you can define the report parameter as Datetime type
and use the following expression:
=Today()
this will return the DateTime object of today. And when you want to
display a formatted datetime string upon this paramter, you can use the
format function in the certain ReportItem's expression, e.g
=Parameters!Today_Param.Value
You can try this to see whethe it also works.
Hope this helps.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

No comments:

Post a Comment