Querying on date range issue?
Hi,
I'm looking for a solution for this issue,
In the DB Table there is a column of type TIMESTAMP. so when i query for date range using BETWEEN keyword it returns data inserted on next day at 12.00.00 AM
example :
Table A
ColumnA_
data1
data2
data3
ColumnTime_
08/03/2010 11.55.00 AM
08/04/2010 12.00.00 AM
08/04/2010 12.00.01 AM
here when I query using between (08/03/2010 and 08/04/2010) keyword on Column_Time then ,
Ouput
data1
data2
but I'm just looking for data1 in the output, any ideas?
Between is inclusive of both boundaries:
column between condition1 and condition2Translates into
condition1 >= column
and
condition2 <= columnSo tell the code what you want ... in your case
condition1 >= column
and
condition2 < columnI'm not sure if you expect the >= or not...adjust as needed.
Similar Messages
-
ACI - Date Range issue for Sales Details report
I am working on ACI setup for one of my client. I set everything us as per documentation.
This is regarding ‘Sales Details’ (Public Folders > ATG > Commerce > Sales > All Sales) report.
Report is being generated if I select ‘Date Range’ under ‘Time Period’; but if I select ‘Predefined’ I get below errors:
RQP-DEF-0177
An error occurred while performing operation 'sqlPrepareWithOptions' status='-9'.
UDA-SQL-0107 A general exception has occurred during the operation "prepare".ORA-32035: unreferenced query name defined in WITH clause RSV-SRV-0042 Trace back:RSReportService.cpp(758): QFException: CCL_CAUGHT: RSReportService::process()RSReportServiceMethod.cpp(239): QFException: CCL_RETHROW: RSReportServiceMethod::process(): promptPagingForward_RequestRSASyncExecutionThread.cpp(774): QFException: RSASyncExecutionThread::checkExceptionRSASyncExecutionThread.cpp(211): QFException: CCL_CAUGHT: RSASyncExecutionThread::run(): promptPagingForward_RequestRSASyncExecutionThread.cpp(824): QFException: CCL_RETHROW: RSASyncExecutionThread::processCommand(): promptPagingForward_RequestExecution/RSRenderExecution.cpp(593):
Has anybody come across this issue?
Any help in this regard will be highly appreciated.
Thanks,
MukeshContact Oracle support. I think we've seen this one before if using a particular version of Oracle(11.1?). There's a particular version of Oracle that doesn't support queries in a WITH clause that aren't referenced in the main query. Cognos seems to generate these types of queries not knowing that the version of Oracle doesn't support it. According or Support Article ID 1063400.1 you can patch this particular problem with Oracle or you can upgrade to Oracle 11.2. I also think that was a to get Cognos to generate an alternative query that doesn't use the WITH clause at all. Something about disabling the use of WITH in all queries by making a change to the report definition or alternatively a global change to the metadata model.
Good luck...
Andrew -
Hi Experts,
I have created a linked server to connect to mysql DB . The query is executing fine currently filter is based on the on going month.
The query actually fetches the records from 2 tables User and time sheet to find how many hours the users have .
Now we check the Hours for a period of 10th of the current month and 10th of the upcoming month .
So for now date range will be between 2014/10/05 and 2014/10/06. This logic i have implemented in the query .
Based on the query a report is generated which is sent out every Wednesday .Now suppose its 5th of June 2014 .
The query will fail because the date range is derived based upon
where cast(t.created_on as Date) > Concat(year(now()),"-",month(now()),"-","10")
AND cast(t.created_on as Date) <=Concat(year(now()),"-",month(now())+1,"-","10")
Please provide with a date filter like the report runs anytime the data is not affected. Like if the report is run in the
first week of a new month date range should be previous month Date 10 and current month Date 10 and if the report is run after 10th of the current month then the date range should be between 10th of current month and 10 of upcoming month . Kindly
help
Select * From
OPENQUERY
(Mysql,
'Select
Sum(t.hours),
Concat(u.firstname," ",
u.lastname) as Name
From mysql.time_entries t
Inner Join
users u
on u.id = t.user_id
where cast(t.created_on as Date) >
Concat(year(now()),"-",month(now()),"-","10")
AND
cast(t.created_on as Date) <=Concat(year(now()),"-",month(now())+1,"-","10")
Group By u.firstname,u.lastname
Union all
Select Sum(0) as hours,
Concat(firstname," ",
lastname) as Name
from users
where id not in(
Select
t.user_id
From mysql.time_entries t
Inner Join
users u
on u.id = t.user_id
where cast(t.created_on as Date) >
Concat(year(now()),"-",month(now()),"-","10")
AND
cast(t.created_on as Date) <=Concat(year(now()),"-",month(now())+1,"-","10"))
And firstname not in( "xyz")
GRoup by firstName,lastname'
goI recommend use CLOSED-OPEN dates rather than OPEN-CLOSED dates...
Hopefully this helps with your logic:
DECLARE @ReportDate TABLE
[ReportDate] DATE,
[mDay] AS DAY([ReportDate]),
[Beg] AS DATEADD(month, CASE WHEN DAY([ReportDate]) < 10 THEN -1 ELSE 0 END, [ReportDate]),
[End] AS DATEADD(month, CASE WHEN DAY([ReportDate]) < 10 THEN 0 ELSE 1 END, [ReportDate]),
[ReportBeg] AS DATEADD(month, CASE WHEN DAY([ReportDate]) < 10 THEN -1 ELSE 0 END, DATEADD(day, 10 - DAY([ReportDate]), [ReportDate])),
[ReportEnd] AS DATEADD(month, CASE WHEN DAY([ReportDate]) < 10 THEN 0 ELSE 1 END, DATEADD(day, 10 - DAY([ReportDate]) + 1, [ReportDate]))
INSERT INTO @ReportDate(ReportDate)
VALUES
('7-May-2014'),
('10-May-2014'),
('15-May-2014');
SELECT
CASE WHEN SYSDATETIME() >= [ReportBeg] AND SYSDATETIME() < [ReportEnd] THEN 1 ELSE 0 END
FROM @ReportDate; -
Hi, I am using Oracle 10g. I want a query which gives me below output.
Data Setup
========
create table t_date_range (
ID number (2),
start_date date,
end_date date);
insert into t_date_range values (1,to_date('20110101', 'YYYYMMDD'),to_date('20110331', 'YYYYMMDD'));
insert into t_date_range values (2,to_date('20110401', 'YYYYMMDD'),to_date('20110531', 'YYYYMMDD'));
insert into t_date_range values (3,to_date('20110701', 'YYYYMMDD'),to_date('20110731', 'YYYYMMDD'));
insert into t_date_range values (4,to_date('20110901', 'YYYYMMDD'),to_date('20111130', 'YYYYMMDD'));
insert into t_date_range values (5,to_date('20111201', 'YYYYMMDD'),to_date('20111231', 'YYYYMMDD'));
commit;
SQL> select ID, to_char(start_date,'DD-MON-YYYY') START_DATE, to_char(end_date,'DD-MON-YYYY') END_DATE from t_date_range;
ID START_DATE END_DATE
1 01-JAN-2011 31-MAR-2011
2 01-APR-2011 31-MAY-2011
3 01-JUL-2011 31-JUL-2011
4 01-SEP-2011 25-OCT-2011
5 26-OCT-2011 30-NOV-2011
6 01-DEC-2011 31-DEC-2011
6 rows selected.
I want result in this form:
START_DATE END_DATE
01-JAN-2011 31-MAY-2011
01-JUL-2011 31-JUL-2011
01-SEP-2011 31-DEC-2011
Means if there is a difference of exact one day between "start_date of 2nd row" and "end_date of first row" then make a single row as shows in above results set.
Thanks!Hi,
Solomon Yakobson wrote:
Keep in mind, Franks's solution assumes date ranges do not overlap. ...That's true. If rows can overlap, then we might need to use two sub-queries, like you did: one to see if a new group starts with this row, and another to count how many new groups have already started.
The solution you posted assumes a relationship between id and dates. If we add a row like this to the sample data:
insert into t_date_range values (6,to_date('20101201', 'YYYYMMDD'),to_date('20121231', 'YYYYMMDD'));that overlaps all the others, then how would that solution work?
LAG won't work, because no matter how we sort the rows, we can't be sure that overlapping rows will be consecutive.
Here's one way to handle overlapping rows:
WITH got_new_grp AS
SELECT id, start_date, end_date
, CASE
WHEN start_date > 1 + MAX (end_date) OVER ( ORDER BY start_date
, id
ROWS BETWEEN UNBOUNDED PRECEDING
AND 1 PRECEDING
THEN 1
END AS new_grp
FROM t_date_range
, got_grp AS
SELECT start_date, end_date
, COUNT (new_grp) OVER ( ORDER BY start_date
, id
) AS grp
FROM got_new_grp
SELECT MIN (start_date) AS start_date
, MAX (end_date) AS end_date
FROM got_grp
GROUP BY grp
ORDER BY start_date
;This solution uses id (assumed to be unique) just to get a consistent ordering, in case 2 (or more) rows have exactly the same start_date. It does not assume any relationship between ids and either start_date or end_date.
I'm also assuming that start_date<=end_date on each row.
Edited by: Frank Kulash on May 11, 2011 12:54 PM
The above refers to the solution you oriognally posted, which was:
with t1 as (
select id,
start_date,
end_date,
case
when lag(end_date) over(order by id) + 1 >= start_date then 0
else 1
end start_of_group
from t_date_range
t2 as (
select id,
start_date,
end_date,
sum(start_of_group) over(order by id) grp
from t1
select min(start_date) start_date,
max(end_date) end_date
from t2
group by grp
order by grp
; -
CUIC Hourly Interval Query Throughout Date Range (SQL Squirrel Stuff)
I’m trying to create a specific report in CUIC using the "Contact Service Queue Activity Report by Interval” canned report. The objective is to query intervals (by hour), throughout the whole reporting time frame. This can be done by interval and reported per day in the canned report, but I’m trying to get the values per interval without the day displayed. For example, I’d like a report that shows total calls per hour (8-9 am, 9-10, 10-11am etc) throughout the reporting date range. The report would look like this:
Interval Start Time Interval End Time CSQ Name Calls Presented Handled
8:00:00 AM 9:00:00 AM CSQ_ 41 40
9:00:00 AM 10:00:00 AM CSQ_ 63 60
10:00:00 AM 11:00:00 AM CSQ_ 50 50
Instead of this:
Interval Start Time Interval End Time CSQ Name Calls Presented Handled
3/3/14 8:00 3/3/14 9:00 CSQ_ 16 16
3/3/14 9:00 3/3/14 10:00 CSQ_ 23 21
3/3/14 10:00 3/3/14 11:00 CSQ_ 24 24
3/4/14 8:00 3/4/14 9:00 CSQ_ 13 13
3/4/14 9:00 3/4/14 10:00 CSQ_ 26 25
3/4/14 10:00 3/4/14 11:00 CSQ_ 14 14
3/5/14 8:00 3/5/14 9:00 CSQ_ 12 11
3/5/14 9:00 3/5/14 10:00 CSQ_ 14 14
3/5/14 10:00 3/5/14 11:00 CSQ_ 12 12Hi
So you want the report to add up all the calls between 9-10am, e.g. if you run it for a week it would add up the calls for each day between 9 and 10 am and show a single total for that hour?
Aaron -
Hi I am using below query
select count(*) from
select M.Login_name
, P.IND_PROD_LOGIN_ID
, count(P.IND_PROD_LOGIN_ID) over (partition by P.IND_PROD_LOGIN_ID) cnt
from CITI_USER_2.CCS_CUSTOMER_MAST M
, CITI_USER_2.CCS_CUSTOMER_PROD P
WHERE M.CUSTOMER_ID = P.CUSTOMER_ID and P.IND_PROD_LOGIN_ID not like '508127%'
and to_char( M.CREATE_DATE , 'DD/MM/YYYY') = '16/10/2009'
) where cnt = 1
and translate(Login_name,'x0123456789','x') is null
and i got the result as 10 records but if i try to put in the date range as below
select count(*) from
select M.Login_name
, P.IND_PROD_LOGIN_ID
, count(P.IND_PROD_LOGIN_ID) over (partition by P.IND_PROD_LOGIN_ID) cnt
from CITI_USER_2.CCS_CUSTOMER_MAST M
, CITI_USER_2.CCS_CUSTOMER_PROD P
WHERE M.CUSTOMER_ID = P.CUSTOMER_ID and P.IND_PROD_LOGIN_ID not like '508127%'
and to_char( M.CREATE_DATE , 'DD/MM/YYYY') between '16/10/2009' and '17/10/2009'
) where cnt = 1
and translate(Login_name,'x0123456789','x') is null
i got the result as 653 records
But it should be 10 only and when i check the records it is giving me wrong result.
Can someone highlight how to use the range between the date, i need to check the number of records between the date range from 01/05/2009 to 01/10/2009this is all happening because of
to_char( M.CREATE_DATE , 'DD/MM/YYYY') between '16/10/2009' and '17/10/2009'in your second query...
that is doing a string comparision not date comparision...
in string comparision
check this example...
select * from dual where '17/10/2009' > '16/10/2010'which will result a record but you might also observe that 17 th in 2009 is less than 16th of 2010. this is because here string comparision is ocurring.
you need to change it as....
M.CREATE_DATE between to_date('16/10/2009','DD/MM/YYYY') and to_date('17/10/2009','DD/MM/YYYY')so your query becomes...
select count(*) from
select M.Login_name
, P.IND_PROD_LOGIN_ID
, count(P.IND_PROD_LOGIN_ID) over (partition by P.IND_PROD_LOGIN_ID) cnt
from CITI_USER_2.CCS_CUSTOMER_MAST M
, CITI_USER_2.CCS_CUSTOMER_PROD P
WHERE M.CUSTOMER_ID = P.CUSTOMER_ID and P.IND_PROD_LOGIN_ID not like '508127%'
and M.CREATE_DATE between to_date('16/10/2009','DD/MM/YYYY') and to_date('17/10/2009','DD/MM/YYYY')
) where cnt = 1
and translate(Login_name,'x0123456789','x') is null check your answer and get back.
Ravi Kumar
Edited by: ravikumar.sv on Oct 16, 2009 3:12 PM -
Query for date range? DPL
Sorry if this has been answered before, but I couldn't find the answer. I'm new to the DPL and was trying to find out how to query for objects that fall within a "date range". If I have an object that has a field "effective date", I would like to query for a list of objects that fall between a date range. Can I do this with DPL?
thanks,
JohnHi,
Yes, the DPL can be used to iterate over the entities where a given date field D falls with a specified date range. To do this, you define D as a @SecondaryKey, create a SecondaryIndex for it, and get a cursor for the specified range using one of the SecondaryIndex.entities() methods. Be sure to close the cursor.
See the Key Ranges section in this class description:
http://www.oracle.com/technology/documentation/berkeley-db/je/java/com/sleepycat/persist/EntityCursor.html
Dates are treated as long values, so a range of Date keys is no different that a range of long keys. Date and long are both "simple types" according to the DPL definition.
--mark -
Query for date range? JE
Hi,
I have seem some posts on the JE forum regarding quering for date range, but it is mostly using DPL.
Is there any way to do that using the JE API
Thanks,
MohammadHi Mohammad,
A date range query can be performed as a key range query. There's nothing special about dates except that you'll want to use a key binding that gives a meaningful sort order. If you're representing your dates in milliseconds, then a LongBinding (in com.sleepycat.bind.tuple) will work well. In general, use tuple bindings for keys, because they provide a meaningful sort order.
To perform a range query, this FAQ has some hints:
http://www.oracle.com/technology/products/berkeley-db/faq/je_faq.html#28
On range searches in general, they can be done with Cursor.getSearchKeyRange or with the SortedSet.subSet and SortedMap.subMap methods, depending on whether you are using the base API or the Collections API. It is up to you which to use.
If you use Cursor.getSearchKeyRange you'll need to call getNext to iterate through the results. You'll have to watch for the end range yourself by checking the key returned by getNext. This API does not have a way to enforce range end values automatically.
If you use the Collections API you can call subMap or subSet and get an Iterator on the resulting collection. That iterator will enforce both the beginning and the end of the range automatically.
Does this answer your question?
--mark -
XL Reporter: Date Range issues
I would like to setup a P&L to get the data from a date range.
At the "Advanced Report Buider", tab "Report Default", I entered the following code into "Complete Selection":
PER( Code >= @PeriodStart Or Code <= @PeriodEnd )
@PeriodStart: parameter point to "Code" of "Financial Period" table
@PeriodEnd: another parameter point to "Code" of "Financial Period" table
Everytime I run the report, it gave me the latest balance instead of the balance within the specified date range.
Please kindly advise.
Thanks in advance,
VivianOr is not correct. It should be And.
Thanks,
Gordon -
I have a query that will retrieve order between selected dates. It works great but returns no record if the 2 dates are the same.
Example:
Orders between 9-1-2010 and 9-30-2010 retunes 35 records.
But if I select between -9-25-2010 and 9-25-2010, so I can see all order from this 1 day, it returns 1 records, and I know there are records for that day!
Here's my query:
<%
Dim rsOrders__MMColParam
rsOrders__MMColParam = "1"
If (Request.QueryString("datefrom") <> "") Then
rsOrders__MMColParam = Request.QueryString("datefrom")
End If
%>
<%
Dim rsOrders__MMColParam2
rsOrders__MMColParam2 = "1"
If (Request.QueryString("dateto") <> "") Then
rsOrders__MMColParam2 = Request.QueryString("dateto")
End If
%>
<%
Dim rsOrders
Dim rsOrders_cmd
Dim rsOrders_numRows
Set rsOrders_cmd = Server.CreateObject ("ADODB.Command")
rsOrders_cmd.ActiveConnection = MM_ezcaldatasource_STRING
rsOrders_cmd.CommandText = "SELECT * FROM dbo.orders WHERE (OrderDate between ? and ?) AND Finalized = 1"
rsOrders_cmd.Prepared = true
rsOrders_cmd.Parameters.Append rsOrders_cmd.CreateParameter("param1", 135, 1, -1, rsOrders__MMColParam) ' adDBTimeStamp
rsOrders_cmd.Parameters.Append rsOrders_cmd.CreateParameter("param2", 135, 1, -1, rsOrders__MMColParam2) ' adDBTimeStamp
Set rsOrders = rsOrders_cmd.Execute
rsOrders_numRows = 0
%>2 possible
1) Change the column's data type from a datetime to a date if supported by your DBMS
2) Use date math to always add 1 day to the end date. So instead of the end date of 9-25-2010 (00:00) it will be 9-26-2010 (00:00) -
Querying multiple date ranges in one select
Hello guys,
DDL:
CREATE TABLE DBO.SALES (
TYPE VARCHAR(50)
, REVENUE DECIMAL(19,2)
, SALE_DATE_TIME DATETIME)
What I'm trying to figure out is how I can pass two dates to a where clause querying this table, a start date and an end date. From this I can group up the REVENUE for each TYPE (but there's more):
SELECT TYPE, COUNT(*) AS NBR_OF_SALES, SUM(REVENUE) AS TOTAL_REVENUE
FROM REPORTS.DBO.SALES
WHERE SALE_DATE_TIME BETWEEN @STARTPERIOD AND @ENDPERIOD
GROUP BY TYPE
I'd now like to add a couple of extra columns in the select that calculates the TOTAL_REVENUE equal to the time period of the two dates, but offset by 1 week, 1 month and 1 year, so that would be three columns. I'm guessing this would be possible with a
CROSS APPLY, but I just can't get my head around it at this time. Just for clarity, the expected output would contain these columns:
TYPE, NBR_OF_SALES, TOTAL_REVENUE, TOTAL_REVENUE_LAST_WEEK, TOTAL_REVENUE_LAST_MONTH, TOTAL_REVENUE_LAST_YEAR
Any help is greatly appreciated.SELECT TYPE,
SUM(CASE WHEN SALE_DATE_TIME BETWEEN @STARTPERIOD AND @ENDPERIOD THEN 1 ELSE 0 END) AS NBR_OF_SALES,
SUM(CASE WHEN SALE_DATE_TIME BETWEEN DATEADD(WEEK,1,@STARTPERIOD) AND DATEADD(WEEK,1,@ENDPERIOD) THEN 1 ELSE 0 END) AS NBR_OF_SALES_WeekOffset,
SUM(CASE WHEN SALE_DATE_TIME BETWEEN DATEADD(MONTH,1,@STARTPERIOD) AND DATEADD(MONTH,1,@ENDPERIOD) THEN 1 ELSE 0 END) AS NBR_OF_SALES_MonthOffset,
SUM(CASE WHEN SALE_DATE_TIME BETWEEN @STARTPERIOD AND @ENDPERIOD THEN REVENUE ELSE 0 END) AS TOTAL_REVENUE,
SUM(CASE WHEN SALE_DATE_TIME BETWEEN DATEADD(WEEK,1,@STARTPERIOD) AND DATEADD(WEEK,1,@ENDPERIOD) THEN REVENUE ELSE 0 END) AS TOTAL_REVENUE_WeekOffset,
SUM(CASE WHEN SALE_DATE_TIME BETWEEN DATEADD(MONTH,1,@STARTPERIOD) AND DATEADD(MONTH,1,@ENDPERIOD) THEN REVENUE ELSE 0 END) AS TOTAL_REVENUE_MonthOffset
FROM REPORTS.DBO.SALES
WHERE SALE_DATE_TIME BETWEEN @STARTPERIOD AND DATEADD(MONTH,1,@ENDPERIOD)
GROUP BY TYPE
Is this what you want?
We have three total columns per metric, one for the period, one for the period offset by a week, and one for the period offset by a month.
We've also adjusted the where so all the data for the offset period is included. -
DB version 10g
a sample table is
my tab
(dt date,
status varchar2(2))
status in ('M','L','H') (medium,low,high)
sample data are: (date in 'dd-mm-yyy hh24Mi:ss' format)
DT STATUS
02-03-2006 08:16:00 H
02-03-2006 08:20:11 H
02-03-2006 08:22:00 H
02-03-2006 08:23:22 H
02-03-2006 08:24:33 M
02-03-2006 08:25:44 H
02-03-2006 08:26:55 L
02-03-2006 14:27:59 L
03-03-2006 00:00:00 L
I'm interested in find duration for every status:
status H
from 02-03-2006 08:16:00 to 02-03-2006 08:24:33 => duration 8 min 33 secs;
from 02-03-2006 08:25:44 to 02-03-2006 08:26:55 => duration 1 min 11 secs;
status M
from 02-03-2006 08:24:33 to 02-03-2006 08:26:55 => duration 1 min 11 secs;
status L
from 02-03-2006 08:26:55 to 03-03-2006 00:00:00 => duration 15 h ....
there are a complex query for this purpose without using a procedure that scan all records to find the chenges of status?Not very elegant:
SQL> select * from my_tab;
DT ST
02-03-2006 08:16:00 H
02-03-2006 08:20:11 H
02-03-2006 08:22:00 H
02-03-2006 08:23:22 H
02-03-2006 08:24:33 M
02-03-2006 08:25:44 H
02-03-2006 08:26:55 L
02-03-2006 14:27:59 L
8 rows selected.
SQL> select status, min(dt), max(ld) from (
2 select status, dt,
3 case when lead(dt) over(order by dt) is null then
4 trunc(dt) + 1 else lead(dt) over(order by dt) end ld,
5 (row_number() over(order by dt) -
6 row_number() over(partition by status order by dt)) gr
7 from my_tab
8 ) group by status, gr
9 /
ST MIN(DT) MAX(LD)
H 02-03-2006 08:16:00 02-03-2006 08:24:33
H 02-03-2006 08:25:44 02-03-2006 08:26:55
L 02-03-2006 08:26:55 03-03-2006 00:00:00
M 02-03-2006 08:24:33 02-03-2006 08:25:44Probably a mistake in M example - if I interpret your question right,
M has to be from 02-03-2006 08:24:33 to the next "H" e.g. 2006 08:25:44 ?
Rgds. -
Need an MDX query for Date range
Hi there,
My requirement is to filter sales from 1st of month to until holiday of the month. I am able to use to ":" range function for filtering, but I am not able to filter on holiday date. Becuase both filter and exists are giving set results, I need
member expression to use range function. Please let me know ASAP.
Thanks,
ATRSAMSHi ATRSAMS ,
You can get the first member of the month with the OpeningPeriod function, and item(#) to have a specific member from a set .
So if you want first member from your set : filter(.....).ITEM(0)
Regards, David . -
Date Range - Delete ZERO Values
Hi All,
Few days back I had posted Query Regarding Date range where in I enter Proj# from_month, from_year, To_month and To_year.
The output data for the project must be within this year range.
suppose I enter proj no. 13381 and
from_month - 05
from_year - 2004
To_month - 04
from_year - 2005
This is the Desired Output:
yearmonth plan14
200406 -
13381 -
100
200407 -
13381 -
100
200409 -
13381 -
678
Right Now the Output what Iam getting is:
yearmonth plan14
200405 -
13381 -
0
200406 -
13381 -
100
200407 -
13381 -
100
200408 -
13381 -
0
200409 -
13381 -
678
I Just want the NON ZERO PLan14 values. The PLan14 values with '0' should be deleted .
Below is the Jist of the code.
RANGES: S_GJAHR FOR COSP-GJAHR,
R_YEAR FOR COSP-GJAHR,
R_DATE FOR PROJ-ERDAT,
R_MONTH FOR CKML1-POPER,
S_OBJNR FOR COSP-OBJNR,
S_KSTAR FOR COSP-KSTAR.
DATA: MNT_INDX(20) TYPE C,
HLD_INDX(3) TYPE N.
DATA: W_MTH(2) TYPE N,
W_DATE LIKE PROJ-ERDAT.
DATA: BEGIN OF ITAB_OUT_TYPE,
PERIOD(10) TYPE C,
PROJDEF(20) TYPE C,
PROJ_TITLE(20) TYPE C,
STATUS(20) TYPE C,
PROJECT_TYPE(20) TYPE C,
START_DATE(20) TYPE C,
FINISH_DATE(20) TYPE C,
CONTRACT(20) TYPE C,
CLIENT(20) TYPE C,
PLAN14(25) TYPE C,
END OF ITAB_OUT_TYPE.
DATA ITAB_OUT LIKE ITAB_OUT_TYPE OCCURS 10 WITH HEADER LINE.
FIELD-SYMBOLS <FS>.
PARAMETERS FR_MONTH(2) TYPE N OBLIGATORY.
PARAMETERS FR_YEAR(4) TYPE N OBLIGATORY.
PARAMETERS TO_MONTH(2) TYPE N .
PARAMETERS TO_YEAR(4) TYPE N .
DATA: W_TXT(20) TYPE C.
R_YEAR-LOW = FR_YEAR.
R_YEAR-HIGH = TO_YEAR .
R_YEAR-OPTION = 'BT'.
R_YEAR-SIGN = 'I'.
APPEND R_YEAR.
concatenate FR_YEAR FR_MONTH INTO R_DATE-LOW .
concatenate TO_YEAR TO_MONTH INTO R_DATE-HIGH.
R_DATE-OPTION = 'BT'.
R_DATE-SIGN = 'I'.
APPEND R_DATE.
SELECT * FROM COSP
WHERE OBJNR = PRPS-OBJNR AND
GJAHR IN R_YEAR AND
KSTAR BETWEEN '0000400996' AND '0000400999' AND
VERSN = '014' AND
WRTTP = '01' .
DO 12 TIMES.
W_MTH = SY-INDEX.
CONCATENATE COSP-GJAHR W_MTH INTO W_DATE.
CHECK W_DATE IN R_DATE.
PERFORM CONVERT-DATE1 USING W_DATE.
MOVE HOLDDATE1 TO ITAB_OUT-PERIOD.
HLD_INDX = SY-INDEX.
CONCATENATE 'COSP-WKG' HLD_INDX INTO W_TXT.
ASSIGN (W_TXT) TO <FS>.
CLEAR ITAB_OUT-PLAN14.
ITAB_OUT-PLAN14 = ITAB_OUT-PLAN14 + <FS>.
APPEND ITAB_OUT.
enddo.
ENDSELECT.
I need all positive values of the month that are in the range. The Zero values must be deleted . How can i do that. PLease do let me know.
Thanks in advance
DanYou can do this easily just by deleting all records in one shot.
delete ITAB_OUT where plan14 = 0.
You can put that statement after the SELECT...ENDSELECT.
Or you can not even add them to the internal table at all. You can check before you APPEND to the table.
CLEAR ITAB_OUT-PLAN14.
ITAB_OUT-PLAN14 = ITAB_OUT-PLAN14 + <FS>.
<b>If itab_out-plan14 > 0.
APPEND ITAB_OUT.
endif.</b>
enddo.
ENDSELECT.
Regards,
Rich Heilman -
Date range to be displayed & Displaying multiple values on the report
Hi,
I have date range parameters, but I also need it to be displayed it on the report. Is there any way I can display it. E.G If a parameter is created one can drag and drop it on the report if it needs to be displayed on the report, I tried to do the same for the date range parameter but it does not work.
Also If a parameter is created by selecting the option 'Allow Multiple Values', and if you drag and drop it on the report only the first value is displayed and the rest does not show. Has anyone tried this before and been successful in displaying multiple values in the report.
Thanks in advance.Hi,
A multi-value parameter is actually treated as an array in Crystal Reports.
To display the values selected in the parameter, create a formula from the Field Explorer and type this code:
Join({?ParameterName},",");
Place this formula on the header or the footer sections of the report.
Regarding the date range issue, please follow Sastry's advice and it should work fine.
Make sure you're using the parameter in the Minimum and Maximum functions. For eg: If I was to create a date range parameter called OrderDate, my formula to show the start date would look like this:
Minimum({?OrderDate})
-Abhilash
Maybe you are looking for
-
Signed applet runs in Firefox but not in Internet Explorer
I've signed an applet with keytool -genkey -validity 3650 -keyalg rsa -alias ddkey keytool -export -alias ddkey -file ddcert.crt jarsigner planner.jar ddkey jarsigner -verify -verbose -certs planner.jar but loaded from the webserver with... <!DOCTYPE
-
Project iMac Screen to Apple TV?
Does the old Apple TV have the ability to receive screen projections or streaming from my iMac to then be seen on my TV?
-
Qosmio G40-11D not booting on battery
Hi, I buyed recently a Qosmio G40-11D. Everything looks ok but today when I tried to boot the PC without main power connected ... surprise ... NO BOOT. Anybody has an ideea on how to fix this please. Thank you for any hint. Andrei
-
Where I can find doc about schemas of DB Secure Search 10.1.8.2?
Hello ALL, I use SES 10.1.8.2 and I very interesting to find documentation about structure of DB SES 10.1.8.2. I mean what information contains in every schemas ? Please give me reference for official documentation Best Regards
-
Send all contacts via bluetooth
hi, i broke my screen on my n82 I lost my datacable, and i have not been able to pair the phone with my computers bluetooth. i need my contacts, i mean ideally i'd like my files too, but they are less important. what i need to know (and i know its a