For reports that contain dates as filters that have been set to Prompt, it is helpful for the selected date range to appear within the report.  While the Prompt Summary() function includes this information, along with other data that has been prompted, the format may not be appealing.

Instead, you can create variables that will capture the dates entered by a user when refreshing the report.  To do this, you'll need to use the same language as in the date prompts.  If automated filters (Active Filter, Enrolled Filter, Dismissed Filter) are being used, the prompt language is "Begin Date" and "End Date".  We'll assume for this example that this is the case.  Note that most dates retrieved via user prompt include a time stamp.  The time stamp must be removed in order to use the resulting date in a calculated formula.  It does not need to be removed if the final date variable will be used only for display.

Open the Variable Editor and call the variable "Begin Date".  Insert the following formula:

 

=ToDate(Left(UserResponse("Begin Date");Pos(UserResponse("Begin Date");" ")-1);"MM/dd/yyyy")

 

Now, make a duplicate of the Begin Date variable, and rename it "End Date".  Simply change the "Begin"  in the formula so that it now reads:

 

=ToDate(Left(UserResponse("End Date");Pos(UserResponse("End Date");" ")-1);"MM/dd/yyyy")

To understand this formula, break it down from the innermost nesting:

Pos(UserResponse("End Date");" ")  The purpose of this formula segment is to find the position (POS) of the space in the date-timestamp that is returned with the prompt. The space occurs between the date and the time stamp.

 

Left(UserResponse("End Date"); ....-1)  This nesting around the ..... which represents the first part above, takes the position that was found, moves it left by one space and then removes everything after that.  In other words, it retains only the leftmost part of the resulting date from the space to the left.

=ToDate(.....;"MM/dd/yyyy")  The outermost nesting of this formula takes the final date without the timestamp and turns it into a date structure that WebI can understand.

Now you have a clean date that can be used in your report for display or for use in a formula:

Display example:      ="Date Range of Report " + [Begin Date] + " - " + [End Date]

Formula example:     =DaysBetween([Date Taken];[End Date])

Did this answer your question?