Link to home
Start Free TrialLog in
Avatar of Gene Moody
Gene MoodyFlag for United States of America

asked on

Today's Date in Report Services 2008?

I have Report Services 2008 running against an Oracle database.  The problem occurs when I want to use SYSDATE in my SQL code - SSRS errors out with ORA-00904 "SYDATE": invalid identifier.

Last I checked, SYSDATE worked just fine, valid and all.

To prove this, I run the SQL code through *any* other interface (like Toad, for instance) and it works just fine.  So SYSDATE is valid.  Except for when you're using SSRS 2008, apparently.

So I look across the 'net, and get told "you have to build a parameter" for that.  Fine.  I do, and it's called THISDAY, and it's definition is (Fx) '=Today' <---literally that simple.  Well, now it puts a text block at the top of the report form BEFORE the report runs, looking for a value (from the user, of course) for THISDAY, which has already been defined as being '=Today'.

Aaargh!  Something this simple shouldn't be so flamin' complicated!

How do I use the equivalent of today's date within a SQL query in Microsoft's (Silly) Report Services 2008?

Thanks!  o/
Avatar of Devinder Singh Virdi
Devinder Singh Virdi
Flag of United States of America image

As per your error ORA-00904 "SYDATE": invalid identifier.

You are not ussing SYSDATE, but SYDATE.
Avatar of Gene Moody

ASKER

Typo on my part: rest assured it is rejecting the keyword SYSDATE.   I'll edit that, if possible...
Okay, I can't edit my initial post.  Pity.  But the problem remains.  SYSDATE doesn't appear to work if called from within a Report Services Query, and for reasons I cannot fathom, I cannot set up a simple "stand in" parameter to provide the value "Now" or "Today".  Seems rather strange.
SYSDATE is oracle internal variable and therefore ORA-00904 should not throw this error.
If we want to reproduce this error, perform the following:-

select "SYSDATE" from dual;
       *
ERROR at line 1:
ORA-00904: "SYSDATE": invalid identifier




select 'SYSDATE' FROM DUAL;

'SYSDATE'
--------------------------------
SYSDATE


select SYSDATE  FROM DUAL;
SYSDATE
---------
01-FEB-13


Therefore check for single and double quotes: -
Okay, this is what the code looks like:

SELECT DISTINCT v.VIN_Number
FROM veh_master v
INNER JOIN veh_bld d ON v.VIN_Number = d.VIN_Number
WHERE d.bdate > sysdate
AND v.vehType in ('F','S')
AND v.constPlan is not null
AND v.VIN_Number not in (select VIN_Number from veh_opt where subtype ='SINGLEAXLE')

Open in new window


When I run it from Toad, it takes a few seconds, then returns about eighty rows, all VINs.  So I know the SQL code works: it's already been tested.

Until I drag it into Report Services.  I create the report, set up the DataSource, then paste in the SQL code (above, which works elsewhere, tested).  At that point  I start catching errors about SYSDATE.  Which I need, because that's Today's Date, which is the beginning of the data in which I am interested.

So: I need to somehow get Report Services to somehow regurgitate Today's Date in a manner that allows me to use it in the SQL report code, as it is necessary to select only VIN's under planning from today forward.  I'm no longer concerned that SYSDATE is throwing an error: I just need to figure out what Report Services needs in that place, or otherwise something generated within Report Services to provide that same info, so that my SQL report can - upon scheduled trigger for eMail subscriptions - provide certain engineers with a heads-up of possible issues for the day, upcoming week.

...and I believe it should really be simple, a lot simpler than it currently appears to be.
ASKER CERTIFIED SOLUTION
Avatar of Gene Moody
Gene Moody
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I should have experimented within the bounds of the SQL Query Designer before getting flustered and making noise over here on EE.  Perhaps, however, this will help some other silent victim, perhaps forced to undertake a previous genius' reporting projects, also with little to no documentation.