none
SSRS Date Parameter - How to remove time from a date/time parameter

    Question

  • I've got a report that uses StartDate and EndDate parameters. I would like to keep the data type as date/time because it allows the user to use a calendar to select a date. This all works fine until I try to specify a default date using a query. I calculate the FirstDayOfMonth and the CurrentDate for the StartDate and EndDate, but when I specify the defaults, the time also displays. Is there a way to keep the parameter as a date/time but not have the time show.  Once the time has displayed, selecting a date using the calendar continues to show the time.

    Before I added the default dates, it worked fine. The user could select the date from the calendar and it only showed the date (not the time). If I convert the default dates to varchar, the report says it is an invalid data type. I know I can change the parameters to 'String' types, but then the user doesn't get a calendar to select the dates if they wish to change them.

    Is there a way to get the best of both worlds? I would like to have the calendar available, but I would also like to specify a default date without showing the time.

    Any help would be greatly appreciated.

    Dave
    Wednesday, January 14, 2009 9:21 PM

Answers

  • Dave,

    The viewer will not show the time part if it's midnight. When you pick a date off of the datepicker, you get midnight on that day, so the viewer doesn't show the time. You can see this clearly by setting your default to "=Today()" and then to "=Now()", and you'll see the difference.

    In your expression or query, if you can drive the time part of the datetime to midnight (00:00:00), the viewer won't show the time part.

    Regards.

    Mike
    Thursday, January 15, 2009 12:59 AM
    Moderator

All replies

  • Dave,

    The viewer will not show the time part if it's midnight. When you pick a date off of the datepicker, you get midnight on that day, so the viewer doesn't show the time. You can see this clearly by setting your default to "=Today()" and then to "=Now()", and you'll see the difference.

    In your expression or query, if you can drive the time part of the datetime to midnight (00:00:00), the viewer won't show the time part.

    Regards.

    Mike
    Thursday, January 15, 2009 12:59 AM
    Moderator
  • Thanks, that did the trick!
    Thursday, January 15, 2009 3:21 PM