Is there a way to set the Parameter Values in the Cache Refresh Plan window to use the previous Sunday? The field is a Date/Time field and will not let me enter code such as =DateAdd(DateInterval.Day, -7,DateAdd(DateInterval.Day, 1-Weekday(today),Today)). It is looking for date format. Thanks in advance
I'm unaware of any parameter caching options. However, you should be able to get a default value to work. Perhaps the expression below will work.
=DateAdd(dd,1- DatePart(dw, CDate(Today())), CDate(Today()))
If you still can't get it to work, another option would be to add a data set that spits out the value. You could use something like:
SELECT DATEADD(dd,1- DATEPART(dw, CAST(GETDATE() AS DATE)), CAST(GETDATE() AS DATE))
Related
new to this world so looking for help with what I think wold be a simple thing to fix, however me and the guy who is training me on all that is SQL and SSRS cannot figure this out
I have a report within SSRS and SQL which is working perfectly bar one thing
I have a drop down list parameter which has all our customers names, and the report shows volumes of what that customer has obtained so far etc, and for an individual customer, this works perfectly. However, when trying to see the total volumes by choosing 'Any' from the drop down list, it returns no data, rather than returning everything
Can anyone please advise what I could be missing here, or what I need to show you to help resolve this issue
Cheers
Liam
Assuming you Stored Proc parameter is varchar and represents either customer names or an 'Any' value then the following should work.
SELECT myField1, myField2 -- etc
FROM myTable t
WHERE (t.ClientName = #myParameterName OR #myParameterName = 'Any')
Optionally Please Note: Personally I don't use SPs and usually just put the code to grab the data in the dataset. Some companies don't like you doing this but if you are able to do this I think this makes life easier.
If you can put the stored proc code directly in your dataset query then you can make the report more flexible. You can change your parameter to be MultiValue, you don't need and 'Any' value added to your parameter list either and then you can simply do something like
SELECT myField1, myField2 -- etc
FROM myTable t
WHERE t.ClientName IN(#myParameterName)
SSRS will take all the selected parameter values and inject them into the dataset query correctly, so there is nothing else you need to do. SSRS will also add a 'Select All' option to your parameter in case you want to gran data for everything. The report will work for 1, 2, 10 or all client names.
FILTER("source"."recordCount" USING "source"."snapshot_date" =
EVALUATE('TO_CHAR(%1, ''YYYYMMDD'')', TIMESTAMPADD(SQL_TSI_DAY, -7, EVALUATE('TO_DATE(%1, %2)', "source"."snapshot_date" , 'YYYYMMDD'))))
So i have this piece of code here. I know some will say "Just use the AGO function" But somehow it's causing problems because of it's connection with other tables so what I'm trying to achieve here is like a remake. The process goes this way:
The snapshot_date there is actually in varchar format and not date. So it's like "20131016" and I'm trying to change it to a date then subtract 7 days from it using the TIMESTAMPADD function and then finally returning it back to varchar to use it with FILTER.
This snippet somehow works when testing the FILTER using hardcoded values like "20131016" for example but when tested out with the code above all the row are blank. On paper, the process i assumed would happen goes lke this. "20131016" turns to a date with a format of 20131016 (yyyymmdd) and then less 7 days: 20131009 and then turned into char again "20131009" to be used in the filter.
But somehow that doesn't happen. I think the data format is not applying either to the string->date or the date->string conversion. which results to the values not getting a match at all.
Anyone have any idea what's wrong with my code?
By the way I've already tried to use CAST instead of EVALUATE or TO_TIMEDATE with the same result. Oh and this goes to the formula of the column in BMM.
Thanks
You might get some clues by looking at the SQL generated by the BI Server. I can't see any issues with your column expression, so I wouldn't limit your debugging to that alone.
A query returning nulls is often caused by incorrect levels being set (especially on logical table sources, but potentially on a measure column too). This will often result in some form of SELECT NULL FROM ... in the physical SQL.
Try this :
FILTER("source"."recordCount" USING "source"."snapshot_date" =
EVALUATE('TO_CHAR(%1, %2)', TIMESTAMPADD(SQL_TSI_DAY, -7, EVALUATE('TO_DATE(%1, %2)', TO_CHAR("source"."snapshot_date" , 'YYYYMMDD') , 'YYYYMMDD')) , 'YYYYMMDD'))
I am trying to create a report in MS Visual Studio and use the DateClosed as a parameter so that a user can select on 'DateClosed'. The error I am getting says:
Error Message: Conversion failed when converting date and/or time from character string.
The select satement is below is based on a view that I had to convert a string (DateClosed) to a datatime data type.
SELECT GrantNumber, GrantAmount, GrantDate, NatureOfGrant, SpecialInstructions, FullName, GMP, GrantType, Name, DateClosed
FROM V_WSF_GrantMakingPartnersGrants
ORDER BY DateClosed DESC
I am really confused because the 'ClosedDate' above is returning the value as a datetime data type. I can't cast it again, because it already sees it as a date. This is making no sense to me.
Can anyone tell me how to add the parameter into MS Visual Studio?
It's not clear where you are getting the data from - SQL Server or Oracle? So you want to pass the date? Ie, you enter 02/02/2012 and then click to generate report?
If you are passing to Oracle, you might have to use the sql function TO_DATE(xxxx). The same thing may apply to SQL Server but that is not an area I'm not familiar with. Therefore:
..order by DateClosed may have to read like this:
to_date(DateClosed, 'yyyy/mm/dd')
The 2nd parameter - must match the date format that you are sending in...
I hope this helps...
I think you should use the dateTime.formate to specify the format type on the dataBase..
like "YYYY-MM-dd". make sure the format is the same date format you are using on your DataBase string date.
I think this will solve your problem.
What I need to do is, in my mind, incredibly simple. So simple in fact that it is probably obvious and therefore I cannot seem to find any place that documents how to do this.
What I need is just to take the value of a Date Picker page Item (:P1_DATE_1) and through a dynamic action set the value of a second Date Picker page Item (:P1_DATE_2). The value of (:P1_DATE_2) should be 2 years, or 730 days, greater than the value of (:P1_DATE_1). So all I need is a simple '+730' expression right?
I had this working using sysdate as the start date for this calculation. The below PL/SQL expression gave the appropriate output:
to_char(sysdate + 730,'dd-MON-rr')
But then I could not get it to translate to accepting the value of the page item. I already have the actions and everything set up I just can't get it to function when I try substituting :P1_DATE_1 for sysdate. I have tried as many different manifestations of that expression using the page item but it does not populate the 2nd page item.
Sorry for the probably stupid question but if anyone could help out I would appreciate it. Thanks!
#Justin Cave is correct: all values in page items are treated as varchar2
As for your dynamic action, this is what i've set up:
Region:
Dynamic action (date 2 add):
True action:
Are you getting an error? If so, what error? Since page items in APEX are always strings, you need to convert them to dates before doing date arithmetic on them. Something like this should work assuming that P1_DATE_1 is in the DD-MON-RR format as well.
to_char( add_months( to_date( :P1_DATE_1, 'DD-MON-RR' ),
24 ),
'DD-MON-RR' )
If you're not getting an error and the second item just isn't defaulting, my guess is that you have an order of operations problem. Are you certain that the first item is actually set to a non-NULL value when the initialization code for the second item is run? If you're trying to set the value in the second item based on a value that the human selects at runtime in the first date picker, you'd either need to submit the page or you'd need a bit of Javascript.
We have a requirement where date time values would be passed to the report parameter which is of "String" date type (and not "DateTime"). The report parameter would be a queried one i.e. it would have a list of values in which the passed value should fall in.
The strange part is that if the date time value passed to this parameter is passed in this format mm/dd/yyyy hh:mm:ss AM/PM then only it succeeds otherwise a error is displayed (If month/date/hour/minute/second is having a single digit value then we need to pass single digit value to parameter as well).
Assuming that the report server picks this format from the "regional settings" in control panel, we tried modifying the date & time formats as yyyy-mm-dd & HH:mm:ss but the outcome was the same.
On researching more I found some suggestions specifying to change the language property in the rdl (I was not able to figure out how) but this would not be the solution I am looking for. I also found another topic here but it didn't provide the solution we are looking for.
I need to understand if this format is controlled at the report server level & is it configurable. It would be great if someone can provide some guidance.
Thanks.
Format(,"mm/dd/yyyy hh:mm:ss AM/PM ")
Then it doesn't matter what the regional settings are.