Solved

How to have report pull data for current date

Posted on 2008-10-30
7
678 Views
Last Modified: 2013-12-19
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

0
Comment
Question by:Jbancr1
  • 3
  • 3
7 Comments
 
LVL 27

Expert Comment

by:sujith80
ID: 22847893
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

0
 

Author Comment

by:Jbancr1
ID: 22848949
sujith80
I get an error message when I run the code you provided.
ORA-01003:  No statment parsed:-1003
0
 
LVL 73

Expert Comment

by:sdstuber
ID: 22849467
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

0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:Jbancr1
ID: 22849628
sdstuber

I get a different error message this time.

ORA-01861: literal does not match format string:-1861
0
 
LVL 73

Expert Comment

by:sdstuber
ID: 22849678
you must not be storing dates as dates.

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

0
 

Author Comment

by:Jbancr1
ID: 22850303
FORMAT FOR END_DATE IS YYYY,MM,DD
0
 
LVL 73

Accepted Solution

by:
sdstuber earned 250 total points
ID: 22851057
I highly recommend you store dates as dates,

but, given your current setup,  try this...
  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 = TO_DATE(SYSDATE, 'yyyy,mm,dd')

GROUP BY so_.zone_code, so_.cust_ship_to_id, FLOOR(SUBSTR(so_.end_time, 1, 2) / 8)

Open in new window

0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello, In my precious Article  (http://www.experts-exchange.com/Database/Reporting/A_15280-Create-Project-in-Microstrategy-Part-I.html)we saw the Configuration part for Microstrategy which included Metadata Creation and DataSource Preparation as …
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.

939 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

1 Experts available now in Live!

Get 1:1 Help Now