Link to home
Start Free TrialLog in
Avatar of Jbancr1
Jbancr1Flag for United States of America

asked on

How to have report pull data for current date

How do you set a report to pull data from current date (today) with out entering todays date?
SELECT so_.zone_code,so_.cust_ship_to_id,
               floor(substr(so_.end_time, 1, 2) / 8) end_time_shift, -- first 2 characters = hour
count(so_.end_time)
       FROM csi.so_pick_detail so_
   WHERE (so_.end_date = @variable ('Date'))
          
           
GROUP BY so_.zone_code,  so_.cust_ship_to_id,
                 floor(substr(so_.end_time, 1, 2) / 8)

Open in new window

Avatar of Sujith
Sujith
Flag of United Kingdom of Great Britain and Northern Ireland image

You can use sysdate to get the current date.
See.
select sysdate from dual;

You may try the below suggestion. I have used a trunc function around the column to make sure that the time components are clipped. L
See whether this does for you.
SELECT so_.zone_code,so_.cust_ship_to_id,
               floor(substr(so_.end_time, 1, 2) / 8) end_time_shift, -- first 2 characters = hour
count(so_.end_time)
FROM csi.so_pick_detail so_
WHERE (trunc(so_.end_date) = trunc(sysdate) )
GROUP BY so_.zone_code,  so_.cust_ship_to_id,
                 floor(substr(so_.end_time, 1, 2) / 8)

Open in new window

Avatar of Jbancr1

ASKER

sujith80
I get an error message when I run the code you provided.
ORA-01003:  No statment parsed:-1003
Avatar of Sean Stuber
Sean Stuber

I recommend doing something like this instead of trunc on your end_date column,
if you have indexes on on the end_time column, writing the query like above will
prevent the use of those indexes, as illustrated below can use indexes.

sujith80's statement looks to be correct syntax though, did you miss a character in a cut-n-paste or something small like that?

  SELECT so_.zone_code,
         so_.cust_ship_to_id,
         FLOOR(SUBSTR(so_.end_time, 1, 2) / 8) end_time_shift,       
         COUNT(so_.end_time)
    FROM csi.so_pick_detail so_
   WHERE so_.end_date >= TRUNC(SYSDATE) AND so_.end_date < TRUNC(SYSDATE + 1)
GROUP BY so_.zone_code, so_.cust_ship_to_id, FLOOR(SUBSTR(so_.end_time, 1, 2) / 8)

Open in new window

Avatar of Jbancr1

ASKER

sdstuber

I get a different error message this time.

ORA-01861: literal does not match format string:-1861
you must not be storing dates as dates.

what is end_date?  A string?  what is the format of it?

Avatar of Jbancr1

ASKER

FORMAT FOR END_DATE IS YYYY,MM,DD
ASKER CERTIFIED SOLUTION
Avatar of Sean Stuber
Sean Stuber

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