Remove Time From SSRS Date Parameter - tsql

I want to remove the time from my Parameter Selection Dropdown, NOT a cell referencing the parameter
I have a simple parameter weekEndingDate which is fed by my dataset
SELECT TOP (8) Convert(Date,FullDate, 101) AS FullDate
FROM DimDate
WHERE (DayNameOfWeek = 'Friday') AND (CAST(FullDate AS Date) < CAST(GETDATE() AS Date))
ORDER BY FullDate DESC
I have also tried
SELECT TOP (8) CAST(FullDate as Date) AS FullDate
FROM DimDate
WHERE (DayNameOfWeek = 'Friday') AND (CAST(FullDate AS Date) < CAST(GETDATE() AS Date))
ORDER BY FullDate DESC
The issue is that the parameter options still display time.
If I execute the query in Query Designer I get basically correct output (Convert is giving me m/dd/yyyy, instead of mm/dd/yyyy) and this is true for cast and convert, but the parameter drop down still has time, and if I put the parameter into a cell, it also has the time
I have deleted the .data files
I have deleted and recreated the parameter, but did not deploy or rebuild or anything WITHOUT the parameter, I deleted and immediately recreated then hit Preview
I have tried both CAST and CONVERT
I have tried Previewing, Running, and Deploying the report
In all cases the time remains and I am dumbfounded, all help appreciated, and I'm happy to clarify anything

Try setting your Parameter Data Type to Text instead of Date/Time.
Also changing the dataset to return varchar was necessary
Final dataset code:
SELECT TOP (8) CAST(CONVERT(Date, FullDate, 101)as VARCHAR) AS FullDate
FROM DimDate
WHERE (DayNameOfWeek = 'Friday') AND (CAST(FullDate AS Date) < CAST(GETDATE() AS Date))
ORDER BY FullDate DESC

Sourced from: https://social.msdn.microsoft.com/Forums/sqlserver/en-US/95d23f74-d7d3-41e1-8538-dbeff6e65ee2/ssrs-2008-r2-parameter-datetime-how-to-hide-time
Open your report in SQL Server Business Intelligence Development Studio or Report Builder3.0.
Click the Design tab, right-click the textbox where you will display the #Time parameter, select expression.
Clear the expression dialog box, then type in:
=FormatDateTime(Parameters!Timer.Value, DateFormat.ShortDate) or =FormatDateTime(Parameters!Timer.Value,2).

Related

How to get data according to a user defined date in Tableau?

I am creating a tableau dashboard and it should load data according to the date the user enters. This is the logic that I am trying.
select distinct XX.ACCOUNT_NUM, (A.TOTAL_BILLED_TOT-A.TOTAL_PAID_TOT)/1000 arrears, ((A.TOTAL_BILLED_TOT-A.TOTAL_PAID_TOT)/1000 - XX.SUM_BILL ) TILL_REF_JUL20
FROM
(
select /*+ parallel (bill ,40 ) */ distinct account_num, sum(INVOICE_NET_mny + INVOICE_TAX_mny)/1000 SUM_BILL
from bill
where account_num in (Select account_num from MyTable)
and trunc(bill_dtm) > ('07-Aug-2021') –-Refmonth+1 month and 07 is a constant. Only month and year is changing
and cancellation_dtm is null
group by account_num
)xx , account a
where xx.ACCOUNT_NUM = A.account_num
Here is what I tried. First created a parameter called ref_Month. Then created a calculated field with this.
[Ref_Month]=MAKEDATE(DATETRUNC('year',(DATEADD('month', 1, [Ref_Month])), 07))
But I am getting an error. I am using a live connection. Is there any method to achive this?
I don't understand what this statement is trying to do:
[Ref_Month]=MAKEDATE(DATETRUNC('year',(DATEADD('month', 1, [Ref_Month])), 07))
If Ref_Month is a date, which it has to be for DATEADD to be a valid operation, why not make it the 7th of whatever starting month and year you are starting with? Then DATEADD('month',1, [Ref_Month]) will be a month later, still on the 7th. So you don't need DATETRUNC or MAKEDATE at all.
That said, how, when, and where are you trying to COMPUTE a PARAMETER,
let alone based on itself?

How to create default date set on a calendar in Tableau

I have one vertica query in my tableau,
select * from mytable where Date(sometimestamp) between
start_date and end_date
As you can see data varies as per change in date range.
My issue is to set start_date as default to current_date - 90 and end_date as current_date.
There is not issue in making end_date as current_date but no idea about how to set start_date as current_date-90 in tableau.
I tried making calculated fields etc but none helps.
Could you please guide me on how to do that.
Note - Both, start_date and end_date should be calendar component not dropdowns or slider.
You can accomplish this by adding a filter to your data source -- note that you won't be able to control this filter from the dashboard (if that's what you want to do, you'll need to create a calculated field and let the users interact with it), rather, this is a datasource level filter.
Go to the data source and click "Add" under the filters text in the top right, then click "Add"
Click the "Relative dates"
Then, select Relative Dates, Months, Last 3 (Or select Days and enter 90 under the "Last" radio button) and press OK.
You said you have the end date handled, but you can create another data source filter to handle the end date if you want.

Date Parameter to Cache SQL

I am very new to Cache. I am trying to develop a report with date parameters. When I issue the SQL command:
SELECT TOP 2 ad.admission_date from system.admission ad WHERE convert(sql_date,ad.admission_date) >= convert(sql_date,'08-01-2014' )
I get what I expect two records.
One of which is 10/1/2010 12:00:00 AM.
Then if I issue the command
SELECT TOP 2 ad.admission_date from system.admission ad WHERE convert(sql_date,ad.admission_date) <= convert(sql_date,'08-01-2014' )
I get no values returned?
When I issue the command
SELECT TOP 2 {fn convert('10-03-2010', sql_date) } FROM system.admission_data
I get two NULL values. Clearly I am confused about how Cache works.
I have found that if you use the standard ODBC format (yyyy-MM-dd) for the date you don't need to use the convert and it is much more efficient:
WHERE ad.admission_date <= '2014-08-01'
I formated date incorrectly. I have my code working now. Should look something like select top 2 convert(DATE, '10/03/2010 12:00:00 AM') .... and then I can actually do comparisons.

SQL Services Reporting Services Cascading Parameter

I have 2 parameters in my report to select a date range:
StartDate & EndDate
I want to hide the StartDate and allow users to just select the EndDate which should then dynamically change the start date to 1 year before the EndDate.
I need this to happen every time a user changes the EndDate changes.
I'm pretty sure I have to use cascading parameters, but I don't know how.
Any suggestions?
Yes, cascading parameters are the trick if you want to do this at the report level. (You could also handle this pretty effectively at the query level.)
First arrange the parameters in your report in order of dependence: EndDate should be be listed above StartDate. Use the up and down arrows to rearrange the parameters.
Set the StartDate parameter to be "Internal" and set the default value appropriately. Select "Specify values" and create a value of =DATEADD( DateInterval.Year, -1, Parameters!EndDate.Value )
Now you can use both #EndDate and #StartDate in your query without initializing them and they will be passed the SSRS value.

Conversion failed when converting date and/or time from character string Error

Select CONVERT(Date, '13-5-2012')
When i run the above T-SQL statement in Management Studio, i get i get the following error:
"Conversion failed when converting date and/or time from character string"
Is there away i can cast that value to a valid Date type successfully? I have such values in a nvarchar(255) column whose dataType i want to change to Date type in an SQL Server table but i have hit that error and i would like to first do a conversion in an Update statement on the table.
Specify what date format you are using:
Select CONVERT(Date, '13-5-2012', 105)
105 means Italian date format with century (dd-mm-yyyy).
Ref: http://msdn.microsoft.com/en-us/library/ms187928.aspx
In general, I'd suspect usually there is data which can't be converted in a column, and would use a case statement checking it's convertable first:
SELECT CASE WHEN ISDATE(mycolumn)=1 THEN CONVERT(Date, mycolumn, [style]) END
FROM mytable
I believe Convert relies on the SQL Server date format setting. Please check your dateformat setting with DBCC USEROPTIONS.
I suspect if you set the dateformat to dmy it'll understand:
SET DATEFORMAT dmy
GO
If even then it doesn't work, you can't find a style that matches your data, and if your data is in a consistant format, it's down to manual string manipulation to build it (don't do this if you can help it).
Try this....
Select CONVERT(Date,'5-13-2012')
Use 'mm-dd-yyyy' format.
CONVERT assumes that the original data can represent a date. One bad data item can throw the same conversion error mentioned here without pointing to the problem.
Using ISDATE helped me get around the bad data items.
SELECT CONVERT(DATE, CONVERT(CHAR(8), FieldName))
FROM DBName
WHERE ISDATE(FieldName) <> 0
You need to give the date format while conversion, this will resolve the error.
select convert(date, '13-5-2012' ,103)