How to use DATE() in SSRS - ssrs-2008

I'm trying to recreate this expression from excel in SSRS:
=((TODAY()-DATE(2016,7,1))/(DATE(2021,6,30) - DATE(2016,7,1)))*100
But I'm getting an error that says date can't be used as a function in SSRS. DateValue converts it to a string and I need to calculate the percentage of time that's elapsed.
Can anyone help?

There is no Date function in SSRS - I think you actually want the DateSerial function.
The date serial function converts a year, month, and day values into a date. You might need to use DateDiff in your calculation - I don't remember if SSRS lets you subtract dates.

Use DateDiff() and CDate():
=(DateDiff("d", Now(), CDate("07.01.2016")) / DateDiff("d", CDate("30.06.2021"), CDate("07.01.2016")) *100

Related

Crystal Reports: using date from the datatime field as a parameter

I am working on a report that I need to add a date range parameter. The field that I need to use in the datetime field, and I need to use the date portion from the field. I tried using the following, but the report returns no result.
cast(StartDateTime as date) between {?StartDate} and {?EndDate}
For the time being, I am using the Select Expert to sort the date range, but I have to manually enter the date in 'yyyy-mm-dd' format. Is there a way to set up the parameter, so that I can use the calendar to choose the dates?
I recommend to use one parameter field and set it to range and date instead of two.
With this you can use easily this formula:
{StartDateTime} = {?Parameter}
If you set the Parameter to Date instead of DateTime it will automatically check with the start of the day for the first range and the end of the day for the last range.

Conversion of Normal Date ( YYYY-MM-DD ) to Julian Date conversion in datastage

Is there any function to convert Normal Date to Julian Date.
I have used JulianDayFromDate function in transformer but i am not getting expected output .
Sample Input :
Date -- 2013-02-02
Output Should be:
Julian Date-- 113033
( In Database we can do the query as below )
select to_date(1900000+113033,'YYYYDDD') from dual
But how to convert in Datastage ... ?
Maybe your expectations are wrong -
2456326 is the julian day for 2013-02-02 - the DataStage functions works.
Check out the Wikipedia documentation for defintions and calculations
Not sure what your 113033 is but it is not the Julian date or Julian day for the date shown.
To achieve what you want you have to do the calculation by your own.
Besides the year calcuation you could use YeardayFromDate to get the daynumer in the year.
So finally it would be something like
YearFromDate('2013-02-02') * 1000 - 1900000 + YeardayFromDate('2013-02-02')
Databases use different "day zero" values for Julian dates. Doesn't matter. The point is the ability to do date (day) arithmetic with them.
To convert back, use DateFromJulianDay() function.

Tableau: Same Day Last Year Auto Filter

I am trying to compare yesterday's data to the same day the year before. For example, yesterday is 11 November 2018. I want to compare to 12 November 2017 (same day but the year before). I am wanting this to be applied automatically on the filter so all I need to do is open the file and verify the numbers are correct before sending off the report.
Any help would be appreciated.
Thanks
There are many Tableau functions that manipulate dates. A couple in particular are relevant to your problem:
Today() - returns the current date
DateAdd() - adds or subtracts an interval from a date. For instance, DateAdd('year', Today(), -1) gives the date one year prior to today. The first argument to DateAdd is the level of granularity or date part.
DateDiff() - determines the difference of the interval between two dates. DateDiff('day', [Start Date], [End Date]) returns the number of days separating the two date arguments.
The functions are well documented in the online help. Construct the formulas you need and filter accordingly.
Isolate yesterday's date as its own field. For instance if that is the max date in your data, then {max([Date])} would create an LOD of the maximum date.
Then make a calculation that will display the same date last year:
year([Date]) = year([max_date])-1
and datepart('week',[Date]) = datepart('week',[max_date])
and datepart('weekday',[Date]) = datepart('weekday',[max_date])

Passing Date Expression in SSRS using fetchXML for CRMDynamics 2016

Quite new to this area so apologies if at all I sound vague. I am trying to create date parameters in SSRS for CRM Dynamics2016.
Objective: To create a drop down containing: Last Year, Last Month, Fiscal Year, Year to Date and use them to filter field: Start Date in a table called Notification and return results
What I have tried before:
Created view with period (this will be like the field label), Begin Date and End Date but I soon realised that CRMDynamics online don't like sql anymore and that they are now more in line with fetchXML
My question is: Is there a way to pass the above mentioned date parameters in SSRS other than what I tried before?
Thanks a ton in advance for all your help!!
Cheers
Salman
The only way to achieve what you are trying to achieve is to dynamically calculate the date range parameters as all of your filter conditions can be broken down to date ranges.
Create a regular SSRS drop down parameter (Name - "DateRange") with all the possible filter conditions LastYear, LastMonth, FiscalYear, YearToDate with the same label and values
Add additional parameters StartDateOnOrAfter and StartDateOnOrBefore, for each specify the "Default Values" as "Specify Values" and use the expression to calculate your parameters, for example:
For parameter - FiscalYear - StartDateOnOrAfter - 01/01/currentyear, StartDateOnOrBefore - 12/31/currentyear
For parameter - LastMonth - StartDateOnOrAfter - Compute 1 day last month, StartDateOnOrBefore - Compute last day last month
... so on and so forth.

SAS Date and substracting 1 Month

I have a date that is stored as a number that is 201401. I would like to subtract 1 month, so that is 201312 and not 201400.
Also, if there is a more efficient way, please suggest as well. I also have the date stored as 01Jan2014, and would be fine converting the SAS date at that point, so that I can create two new columns (with 1 month subtracted) so that they have the value 01Dec2013 and 201312. Also, a function for incrementing the month forward or backward would be much appreciated.
Thanks in advance.
If you store the date as a SAS date, you can use the function intnx to increment it by whatever period you like.
newdate = intnx('Month',olddate,1,'s');
If you store it as an integer like your original, you're on your own to figure that out. My answer: don't.
The prior answer works.
I just wanted to add, storing as Date in SAS is not the same as storing as integer. It may display 01JAN2014 but it represents a number, so you can still perform computations.
If you store the date as a SAS date, you can use the function intnx to increment it by whatever period you like.
newdate = intnx('Month',olddate,1,'s');