Passing date range ??
Post Author: hasan
CA Forum: Formula
I am using ASP.net and SQL server... I have a Selection Formula, that works great when querying my table to generate the report. I am clueless on how to produce a report based on a date range, that a user specifies in the textboxes. I've tried the following with no success:
mySelectFormula = "{ServiceRequest_Table.Dept_Name} = " & """" & Trim(ddlDepartment.SelectedValue) & """ AND {ServiceRequest_Table.Status_Type} = " & """" & Trim(ddlStatusType.SelectedValue) & """ AND {ServiceRequest_Table.UserFullName} = " & """" & Trim(ddlUser.SelectedValue) & """ AND {ServiceRequest_Table.Open_Date} > " & """" & Trim(txtFromDate.Text) & """"
I get this error:
A date-time is required here. Details: errorKind Error in File C:\Users\LCSGLO~1\AppData\Local\Temp\ServiceRequest_Temp_Report {37610816-196F-4EB1-8CB1-C80554C057FD}.rpt: Error in formula . '{ServiceRequest_Table.Dept_Name} = "IT Group" AND {ServiceRequest_Table.Status_Type} = "New" AND {ServiceRequest_Table.UserFullName} = "Hasan Mehmet" AND {ServiceRequest_Table.Open_Date} > "9/30/2007"' A date-time is required here. Details: errorKind
Please any help in regarding this issue would be greatly appreciative.....it has been weeks and it's driving me crazy.
Thanks!!
Step1:- First i create a SSAS datasource. Then i create a cube for my table CacheAttendees.
It has following columns:-
[Cache Attendees].[Conference Id]
[Cache Attendees].[Group Date Count]
[Cache Attendees].[Insert Time Stamp]
[Cache Attendees].[Screen Name]
[Cache Attendees].[User Id]
[Cache Attendees].[User Type Id]
[Cache Attendees].[User Type Name]
[Cache Attendees].[Visit Id]
Step2:- Then i create a dimension with this cube with all columns.
Step3:- Then i deploy my SSAS project.
Step4:- Use SSAS datasource in my SSRS datasource.
Step5:- Create a report with chart control. Add a parameter ConferenceId. Set default to 1. When i preview my report then it show Cache Attendees].[Conference Id].[1] in header of report instead of that, When i pass the parameter value as 1 then report cannot show & throw an error. I want to pass this parameter at runtime.
Step6:- Please help me how is it possible to pass parameter at runtime.
Similar Messages
-
How to pass date range as filter in Go URL
Hi,
I am trying to construct a Go Url which has two filters, date range & text. I have constructed the url as below but it keeps throwing an error. The url is not passing the max date and the application is throwing following error:
Error: State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 46048] Datetime Month value 0 from 0000-00-00 is out of range. (HY000)
Go Url: https:companyUrl?Go&Options=rfd&Path=/shared/CompanyID/Reportlink&P0=2&P1=eq&P2=CustomObject4.%22Indexed%20Pick%201%22&P3=Leasing&P4=bet&P5="- CustomObject4 Custom Attributes".ZDate_26&P6=2+Date%20'2014-08-01'+Date%20'2014-12-31'
Please suggest.
Thanks,
Kiran.Looks like you are converting the datatype from char to date in URL, I dont think this can be done.
Your code is like
&P6=2+Date%20'2014-08-01'+Date%20'2014-12-31'
It suppose to be &P6=2+2014-08-01+2014-12-31
I would suggest to do the formatting for this filed using Column properties and try.
Hope this helps, pls mark if it does ;) -
Pass date range parameter to SQL stored procedure.
Hi,
I'd like to pass a date range parameter from Crystal Reports to a sql stored procedure. Does anyone know if this is possible?
I've had no problem passing standard datetime (single value) paramaters to and from but am struggling with getting a range value parameter to work.
Environment: Crystal Reports 10/XI and SQL 2000 MSDE version or SQL 2005 Express Edition.
Any help would be appreciated.C5112736 wrote:>
> And then these 2 formulas 'Formula # 1' and 'Formula # 2' can be used to pass on to the stored procedure.
Can someone please demonstrate exactly how to use formula results as date parameters to a SQL stored procedure? Keep in mind, there are two parameters to the stored procedure.
I have gleaned this much: Use Add Command and insert the procedure with
EXEC ServerName.dbo.usp_sprocName;1 '{?StringParameter}'
but if I try to do
{CALL ServerName.dbo.usp_SprocName({@Formula1},{@Formula2})}
then it gives the error "No value given for one or more required parameters".
Both of the parameters are VARCHAR(50).
I have finally found this link: [http://msdn.microsoft.com/en-us/library/ms710248(VS.85).aspx|http://msdn.microsoft.com/en-us/library/ms710248(VS.85).aspx]
This Microsoft site defines the format of the ODBC escape sequences, but I still do not know how to convince Crystal to insert it's parameter results or formula results.
Pulling what's left of my hair out . . .
~ Shaun -
Passing date range parameters in MDX Query
Following is my mdx query
SELECT NON EMPTY
[Measures].[Cache Attendees Count]
ON COLUMNS,
NON EMPTY
([Cache Attendees].[Visit Id].[Visit Id].ALLMEMBERS *
[Cache Attendees].[User Id].[User Id].ALLMEMBERS *
[Cache Attendees].[Screen Name].[Screen Name].ALLMEMBERS *
[Cache Attendees].[User Type Id].[User Type Id].ALLMEMBERS *
[Cache Attendees].[User Type Name].[User Type Name].ALLMEMBERS *
[Cache Attendees].[Group Date Count].[Group Date Count].ALLMEMBERS *
[Cache Attendees].[Insert Time Stamp].[Insert Time Stamp].ALLMEMBERS )
DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS FROM
SELECT
STRTOMEMBER(@FromCacheAttendeesInsertTimeStamp) : STRTOMEMBER(@ToCacheAttendeesInsertTimeStamp)
) ON COLUMNS FROM (
SELECT
STRTOSET(@CacheAttendeesConferenceId) ) ON COLUMNS FROM [Cube_Attendee])
WHERE ( IIF( STRTOSET(@CacheAttendeesConferenceId).Count = 1, STRTOSET(@CacheAttendeesConferenceId), [Cache Attendees].[Conference Id].currentmember ) )
CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS
I want to filter my cube with three parameters
1. @CacheAttendeesConferenceId
2. @FromCacheAttendeesInsertTimeStamp
3. @ToCacheAttendeesInsertTimeStamp
When i pass following parameters
ConferenceId = 1, StartDate='2010-01-28T00:00:00', EndDate='2010-02-03T00:00:00'
Then it show records
But When i pass following parameters
ConferenceId = 1, StartDate='2010-01-27T00:00:00', EndDate='2010-02-03T00:00:00'
Then it display message No Data Available
PLease help me on this issue why not FromDate & ToDate range works properly.Step1:- First i create a SSAS datasource. Then i create a cube for my table CacheAttendees.
It has following columns:-
[Cache Attendees].[Conference Id]
[Cache Attendees].[Group Date Count]
[Cache Attendees].[Insert Time Stamp]
[Cache Attendees].[Screen Name]
[Cache Attendees].[User Id]
[Cache Attendees].[User Type Id]
[Cache Attendees].[User Type Name]
[Cache Attendees].[Visit Id]
Step2:- Then i create a dimension with this cube with all columns.
Step3:- Then i deploy my SSAS project.
Step4:- Use SSAS datasource in my SSRS datasource.
Step5:- Create a report with chart control. Add a parameter ConferenceId. Set default to 1. When i preview my report then it show Cache Attendees].[Conference Id].[1] in header of report instead of that, When i pass the parameter value as 1 then report cannot show & throw an error. I want to pass this parameter at runtime.
Step6:- Please help me how is it possible to pass parameter at runtime. -
Regarding Date Range parameter
hello,
in purchase order, i want to pass date range parameter. For eg .
I want to fetch data from 21/11/2011 to 25/11/2011
how to pass parameter for this?? or do i need to create any formula??
if yes then how/???????
awaiting for soonest reply.hi,
you need to do this in the Formula workshop.
this formula {OPOR.DocDate} = {?DateRange}
{OPOR.DocDate} - this is the PO DocDate
{?DateRange} - this is what you have done in step #4 in my 1st post. in this example "DateRange" is the name of my Parameter.
Quote from you post
{OPOR.DocDate} = {?25/11/2011 to 30/11/2011} In this way should i write a formula??????
change this {?25/11/2011 to 30/11/2011} to the name of your Parameter. refer to step #4.
regards
Fidel -
Code or idea of adding date range parameters
Thanks guys for answering all my past queries.
Another question arises
I don't know how to write code for date range value parameters for a report.
i-e
I have a report that takes a start date and end date range parameter.
I can pass all the other parameters to CrystalReportViewer through code but dont know how to write code to pass date range parameters.
Please help!Hi,
I assume you are using JRC on CR XI or XI R2.
For Single Range Values:
Calendar calendar1 = Calendar.getInstance();
calendar1.clear();
calendar1.set(yyyy,mm,dd);
Date date1 = calendar1.getTime();
Calendar calendar2 = Calendar.getInstance();
calendar1.clear();
calendar.set(yyyy,mm,dd);
Date date2 = calendar2.getTime();
// use yyyy,mm,dd,hh,mm,ss for DateTime parameter.
ParameterFieldValue rangeVal = createSingleRangeVal(date1, date2, RangeValueBoundType.inclusive, RangeValueBoundType.inclusive);
paramFieldController.setCurrentValue("", "<Parameter Name>", rangeVal);
For Multiple Range Values:
Object [] beginVals = {date1, date2, date3};
Object [] endVals = {date4, date5, date6};
//Where date1 - date4 is range 1, date2 - date5 is range 2 and date3 - date 6 is range 3.
RangeValueBoundType [] beginBoundTypes = {RangeValueBoundType.inclusive, RangeValueBoundType.exclusive, RangeValueBoundType.noBound};
RangeValueBoundType [] endBoundTypes = {RangeValueBoundType.noBound, RangeValueBoundType.inclusive, RangeValueBoundType.exclusive};
ParameterFieldValue [] multiRangeVal = createMultiValRangeParameter(beginVals, endVals, beginBoundTypes, endBoundTypes);
paramFieldController.setCurrentValues("", "<Parameter Name>", multiRangeVal);
I hope this helps.
Thanks
Aasavari -
Passing a date range to a Crystal Report using OpenDocument
Hi,
I am trying to call up a Crystal report in InfoView using a hyperlink with the OpenDocument function call.
It is working fine with the following URL:
http://<server name>:<port>/OpenDocument/opendoc/openDocument.jsp?sIDType=CUID&iDocID=ARcnOcErTA1FidjRJ_sT0Yw&sType=rpt&sRefresh=Y&lsSCompany+Code=1300&lsMCost+Center=[12345],[67890]&lsSCost+Element=0000100123
However, once I added the date range into the parameter string, like this:
http://<server name>:<port>/OpenDocument/opendoc/openDocument.jsp?sIDType=CUID&iDocID=ARcnOcErTA1FidjRJ_sT0Yw&sType=rpt&sRefresh=Y&lsSCompany+Code=1300&lsMCost+Center=[12345],[67890]&lsSCost+Element=0000100123&lsRFiscal+Year+Period=[Date(1,1,2011)..Date(1,9,2011)]
It returns an error message, "An error has occurred: java.util.Date ", to my browser.
I am wondering if I am missing any Java library or Java class path.
Any thoughts are appreciated.
Joyce
Edited by: Joyce Chan on Aug 30, 2011 12:25 PMHow do I check if the parameter passing in is in date type?
the following is exactly what I've tried:
&lsRFiscal+Year+Period=[Date(2010,10,10)..Date(2010,10,15)]
Would the error message be logged in the server, maybe I can find more information for the error log? -
Pass a date Range from VB to a parameter
Hello,
I'm thinking this is an easy question, but ...
In a Visual Studio 2008 VB program, I'm allowing the user to pick a starting and ending date from DateTimePickers. (works fiine).
In a CR 2008 report, I have a paramter defined as "pDateRange", Type = date, Allow Range Values = Yes.
In the Record Selection, I use a formula of {tblData.INSTALLDT} in {?Date_Range}.
When I run the report, I can enter the date ranges in via the Enter Values prompt screen, and it works file,
All I need to know is - how do I pass the dates the user selected in the VB program to the pDateRange parameter?
Thanks very much,
CarlThanks Ludek for the reply.
Unfortunately, I canu2019t seem to puzzle this out. None of the examples seem to work. This is an example, along with their comments.
I get the error "The parameter field current values cannot contain range values because the ValueRangeKind property is set to discrete." on the last line.
I could REALLY use some help getting past this issue.
Dim myReportDocument As New CRS_Tab_Prod_Org_Cnt_Params2
Dim crParameterFieldDefinitions As ParameterFieldDefinitions
Dim crParameterFieldDefinition As ParameterFieldDefinition
Dim crParameterValues As ParameterValues
Dim crParameterRangeValue As ParameterRangeValue
crParameterFieldDefinitions = myReportDocument.DataDefinition.ParameterFields
'Access the individual subreport parameter field "Date_Range"
crParameterFieldDefinition = crParameterFieldDefinitions.Item("Date_Range")
'Cast the variable to hold the values to pass to the Report before execution
crParameterValues = crParameterFieldDefinition.CurrentValues
'Cast the variable to hold the range value for the parameter
crParameterRangeValue = New ParameterRangeValue()
'Set the Date range and include the upper and lower bounds. Use the Cdate function as insurance
'to ensure that the value passed is cast to the appropriate data type
With crParameterRangeValue
.EndValue = CDate("1/1/1997")
.LowerBoundType = RangeBoundType.BoundInclusive
.StartValue = CDate("12/20/1997")
.UpperBoundType = RangeBoundType.BoundInclusive
End With
'Apply the Date range to the values to be passed to the Report
crParameterValues.Add(crParameterRangeValue)
'Pass the parameter values back to the report
crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)
Thanks for your help,
Carl -
Passing a range of dates from Visual Composer 7.0 to Bex Analyzer
Dear Experts,
I created a button in my Visual Composer model that has the following settings:
System action: Hyperlink
Apply to: Self
Hyperlink address: "...QUERY=BMMSEG_C01_SAS_Q0001&BI_COMMAND_1-BI_COMMAND_TYPE=SET_SELECTION_STATE&BI_COMMAND_1-TARGET_DATA_PROVIDER_REF_LIST-TARGET_DATA_PROVIDER_REF_1=DP_1&BI_COMMAND_1-CHARACTERISTICS_SELECTIONS-CHARACTERISTIC_SELECTIONS_1-CHARACTERISTIC=MBUDAT&BI_COMMAND_1-CHARACTERISTICS_SELECTIONS-CHARACTERISTIC_SELECTIONS_1-SELECTIONS-SELECTION_1-SELECTION_INPUT_STRING=08/22/2006;08/28/2006"
Basically, what I need is to pass a range of dates from Visual Composer to Bex Analyzer on the characteristic "MBUDAT". However, it only brings back the data with those specific dates, not the range.
I don't think this is the correct syntax to pass in a range value: 08/22/2006;08/28/2006 Please advise how should I do it.
Thank you in advance,
KevinHi J GOEL,
Thank you for your quick response. I created a date range variable ZPSTDAT, and then I passed in the oncatenated value to my Bex query (for this example, let says the From date is 08/22/2006, and the To date is 08/28/2006 ).
Here's what I passed in into the url:
...QUERY= BMMSEG_C01_SAS_Q0001
&BI_COMMAND_1-BI_COMMAND_TYPE=SET_SELECTION_STATE
&BI_COMMAND_1-TARGET_DATA_PROVIDER_REF_LIST-TARGET_DATA_PROVIDER_REF_1=DP_1
&BI_COMMAND_1-CHARACTERISTICS_SELECTIONS-CHARACTERISTIC_SELECTIONS_1-CHARACTERISTIC= ZPSTDAT
&BI_COMMAND_1-CHARACTERISTICS_SELECTIONS-CHARACTERISTIC_SELECTIONS_1-SELECTIONS-SELECTION_1-SELECTION_INPUT_STRING= 08/22/2006:08/28/2006
However, it returns all the records, so it seems like it doesn't even accept the range value that I passed into the Bex. Do you mind to please show me the url you have that pass in the date range. I just need to see the date range part, not the entire url.
Thanks,
Kevin -
Passing DateArray or Date Range from formula result to Select Expert
Is there a way to pass Two (2) dates from a single formula to the Select Expert?
I calculate Beginning and Ending dates of periods ie: fiscal year to date, calendar year to date, last calendar quarter. I would like to pass both the beginning and end date to a formula in the Select Expert.
Please show code samples if possible.
ThanksIn your selection criteria, have code similar to this:
datevar begindate; // this is from your formula for date range
datevar enddate; // this is from your formula for date range
{database.datefield} in begindate to enddate;
Edited by: Sanjay Kodidine on Jun 27, 2009 11:43 AM -
MDM ABAP API query to pass the date range
Hi
I want to retrieve certain data from MDM repository based on filter criteria by date stamp.
Not sure how to do it to pass the select option value in the query.
select-options: s_cdate for sy-datum obligatory .
DATA wa_query TYPE mdm_query.
DATA: v_search_date1 TYPE MDM_CDT_DATE_TIME.
data: v_datestamplow1 type string.
data: v_datestamplow type TZNTSTMPL.
concatenate s_cdate-low '000000' into v_datestamplow1
v_datestamplow = v_datestamplow1.
clear wa_query.
wa_query-parameter_code = 'Changed_On '. "Field code ( Field name )
wa_query-operator = 'EQ'.
wa_query-dimension_type = mdmif_search_dim_field. "Field search
wa_query-constraint_type = MDMIF_SEARCH_CONSTR_DATE. "Date serach
I am able to get the data when I just pass the low value from selecct option. But I dont how to pass the date range.
v_search_date1-CONTENT = v_datestamplow.
ET REFERENCE OF v_search_date1 INTO wa_query-value_low.
APPEND wa_query TO gt_query.
CALL METHOD cl_api->mo_core_service->query
EXPORTING
iv_object_type_code = 'Vendors'
it_query = gt_query
IMPORTING
et_result_set = gt_result.
II could see the below operator types . Although EQ says "Like standard select-options parameter" not sure how to pass the value.
EQ Equal to (like standard select-options parameter)
NE Not equal to (like standard select-options parameter)
LT Less than (like standard select-options parameter)
LE Less than or equal to (like standard s-o parameter)
GT Greater than (like standard select-options parameter)
GE Greater than or equal to (like standard s-o parameter
SW Starts with (MDM specific parameter)
Thanks,
Krishna.Hi,
To get the date range for select options, pass the low value with 'GE' operator and another query option with 'LE' operator for high value.
select-options: s_cdate for sy-datum obligatory .
DATA wa_query TYPE mdm_query.
DATA: v_search_date1 TYPE MDM_CDT_DATE_TIME.
data: v_datestamplow1 type string.
data: v_datestamplow type TZNTSTMPL.
concatenate s_cdate-low '000000' into v_datestamplow1
v_datestamplow = v_datestamplow1.
clear wa_query.
wa_query-parameter_code = 'Changed_On '. "Field code ( Field name )
wa_query-operator = 'GE'.
wa_query-dimension_type = mdmif_search_dim_field. "Field search
wa_query-constraint_type = MDMIF_SEARCH_CONSTR_DATE. "Date serach
GET REFERENCE OF v_search_date1 INTO wa_query-value_low.
APPEND wa_query TO gt_query.
concatenate s_cdate-high '235959' into v_datestamphigh1
v_search_date2 = v_datestamphigh1.
clear wa_query.
wa_query-parameter_code = 'Changed_On '. "Field code ( Field name )
wa_query-operator = 'LE'.
wa_query-dimension_type = mdmif_search_dim_field. "Field search
wa_query-constraint_type = MDMIF_SEARCH_CONSTR_DATE. "Date serach
GET REFERENCE OF v_search_date2 INTO wa_query-value_low.
APPEND wa_query TO gt_query.
CALL METHOD cl_api->mo_core_service->query
EXPORTING
iv_object_type_code = 'Vendors'
it_query = gt_query
IMPORTING
et_result_set = gt_result.
Thanks. -
Possible to pass a date range to a subreport?
Hi,
I've created a report with three groups and I suppress the second and third group. The first group displays a summary of the details. If I "hide" the details I have a nice summary looking report which I can then click on to drill down into the details. However, I cannot enable the "hide" functionality because of two reasons: 1. I'm using the crystal java viewer and it has serious limitations when using the hide/drill-down feature; and 2. in order to print I have to click on each group item in order to print - so when I have 20 values in my group I'm going into each group 20 times and printing 20 times.
So, I still want a summary view of all my group summaries at the front of my report. How can I consolidate the group values into a single summary view? I attempted creating a subreport that is the same as the main report however the issue is that the initial parameter used is a date *range". I'd like to pass the date range to the subreport and then I'm sure this would all work. Does crystal support passing a date range to a sub-report? If so, how is this done?
thx!
MarkHi Mark,
Yes, you can pass a date range value to the SUbreport!
Here's how its done:
1) Create a formula in the Main report; call it Start_date:
Minimum({?Date_parameter})
2) Create a second formula in the Main report and call it End_date:
Maximum({?Date_parameter})
3) Insert the sub-report and then Right-click the sub-report > Select Change Subreport links > Move the Start_date and End_date formulas to 'Fields to Link to' area and make sure you uncheck the 'Select data in subreport based on field' option.
4) Edit the sub-report (Right-click > Edit) and insert a Record Selection formula to include the parameters from the Main Report.
Go to Report > Selection Formulas > Record:
{date_field} >= {?Pm-@Start_date} and {date_field} <= {?Pm-@End_date}
Hope this helps!
-Abhilash -
Passing the Date range within the query
Hi ,
In my query , I have two date characteristic, and while doing the selection I have to do selection on only one date field.
This selection is a date range selection , So I have used a selection variable for this.
Can anyone please let me know if it is possible to pass the selection range to other variable. Is it possible to use Customer exit to pass the complete range.
Thanks
AltairHi,
You can do it in the user exit.And that is the only approach to transfer the values of one variable to other variable .
Search this forum for the code. you will find lot of postings.
With rgds,
Anil Kumar Sharma .P -
Date range query problem in report
Hi all,
I have created a report based on query and i want to put date range selection but query giving problem.
If i am creating select list selection then it is working fine means it will display all records on the particular date.
But what i need is that user will enter date range as creation_date1,creation_date2 and query should return all the records between these date range. i want to pass it by creating items, i created two items and passing creation_date range to display all records but not displaying and if not passing date then should take null as default and display all records
Here is the query:
/* Formatted on 2006/12/10 20:01 (Formatter Plus v4.8.0) */
SELECT tsh."SR_HEADER_ID", tsh."SALES_DEPT_NUMBER", tsh."COUNTRY",
tsh."LOCAL_REPORT_NUMBER", tsh."ISSUE_DATE", tsh."SUBJECT",
tsh."MACHINE_SERIAL_NUMBER", tsh."MACHINE_TYPE", tsh."MACHINE_HOURS",
tsh."STATUS"
FROM "TRX_SR_HEADERS" tsh, "TRX_SR_PARTS" tsp
WHERE (tsh.status LIKE :p23_status_sp OR tsh.status IS NULL)
AND (tsh.machine_type LIKE :p23_machine_type_sp)
AND ( tsh.machine_serial_number LIKE
TO_CHAR (:p23_machine_serial_number_sp)
OR tsh.machine_serial_number IS NULL
AND ( TO_CHAR (tsh.failure_date, 'DD-MON-YY') LIKE
TO_CHAR (:p23_failure_date_sp)
OR TO_CHAR (tsh.failure_date, 'DD-MON-YY') IS NULL
AND ( TO_CHAR (tsh.creation_date, 'DD-MON-YY')
BETWEEN TO_CHAR (:p23_creation_date_sp)
AND TO_CHAR (:p23_creation_date_sp1)
OR TO_CHAR (tsh.creation_date, 'DD-MON-YY') IS NULL
AND (tsh.issue_date LIKE :p23_date_of_issue_sp OR tsh.issue_date IS NULL)
AND (tsh.country LIKE :p23_country_sp OR tsh.country IS NULL)
AND ( tsh.local_report_number LIKE TO_CHAR (:p23_local_rep_num_sp)
OR tsh.local_report_number IS NULL
AND ( tsp.part_number LIKE TO_CHAR (:p23_part_number_sp)
OR tsp.part_number IS NULL
AND tsh.machine_type IN (
SELECT DISTINCT machine_type
FROM trx_sales_dept_machine_list
WHERE sales_department_id IN (
SELECT DISTINCT sales_department_id
FROM trx_user_sales_department
WHERE UPPER (user_name) =
UPPER ('&APP_USER.'))
AND SYSDATE >= valid_from)
AND tsh.sr_header_id = tsp.sr_header_id
can any one tell me wat is wroung in this query.
Any other way to write this?
Thank You,
AmitHi User....
Here is some date range SQL that my teams uses with some success:
For date columns that do not contain NULL values, try this (note the TRUNC, it might help with your "today" problem).
The hard coded dates allow users to leave the FROM and TO dates blank and still get sensible results (ie a blank TO date field asks for all dates in the future.
AND TRUNC(DATE_IN_DATABASE)
BETWEEN
decode( :P1_DATE_FROM,
TO_DATE('01-JAN-1900'),
:P1_DATE_FROM)
AND
decode( :P1_DATE_TO,
TO_DATE('31-DEC-3000'),:
:P1_DATE_TO)
For date columns that contain NULL values, try this (a little bit trickier):
AND nvl(TRUNC(DATE_IN_DATABASE),
decode( :P1_DATE_FROM,
decode( :P1_DATE_TO,
TO_DATE('30-DEC-3000'),
NULL),
NULL)
BETWEEN
decode( :P1_DATE_FROM,
TO_DATE('01-JAN-1900'),
:P1_DATE_FROM)
AND
decode( :P1_DATE_TO,
TO_DATE('31-DEC-3000'),
:P1_DATE_TO)
Note the 30-DEC-3000 versus 31-DEC-3000. This trick returns the NULL dates when the FROM and TO date range items are both blank.
I hope this helps.
By the way, does anyone have a better way of doing this? The requirement is given a date column in a database and a FROM and a TO date item on a page,
find all of the dates in the database between the FROM and TO dates. If the FROM date is blank, assume the user want all dates in the past (excluding NULL dates). If the TO date is blank, assume that the user wants all of the dates in the future (excluding NULL dates). If both FROM and TO dates are blank, return all of the dates in the databse (including NULL dates).
Cheers,
Patrick -
Date range selection in abap code in infopackage
Hi!
I have a field called "OPEN_DATE".
When the infopackage is runned, I need the abap code to fint the current date, and from that, make a date range from the first day of current month to the last day of current month
Ex:
Current date = 12.12.2008
Abap code should extract 01.12.2008 - 31.12.2008
Thanks!Hi helge,
Data: l_idx like sy-tabix.
Data: date_low like sy-datum,
date_high like sy-datum.
Date_low = sy-datum.
date_low+6(2) = '01'.
CALL FUNCTION 'SLS_MISC_GET_LAST_DAY_OF_MONTH'
EXPORTING
DAY_IN = Date_low
IMPORTING
LAST_DAY_OF_MONTH = date_high
read table l_t_range with key
fieldname = 'OPEN_DATE'.
l_idx = sy-tabix.
Pass Range values to L_T_Range Table.
Move date_low to L_T_Range -Low.
Move date_high to L_T_Range -High.
L_T_Range -Sign = u2018Iu2019. *****(Here: I u2013 Include, E u2013 Exclude)
L_T_Range -Option = u2018BTu2019.****( Here: BT u2013 Between )
modify l_t_range index l_idx.
p_subrc = 0.
Regards,
Maybe you are looking for
-
We would like for our users to have pdf's the open from the web open in Acrobat 11 instead of opening in their browser (IE 11). I found this article, Acrobat Help | Display PDF in browser | Acrobat, Reader XI, and tested the configuration and it seem
-
Hi experts How to get long text in VD53 transaction Using READ_TEXT Regards Manoj
-
How do I turn off Safari temporarily so I can download software?
How do I turn off Safari? I'm downloading Microsoft Office Mac 11 but procedure stops due Safari application running.
-
Hi All, We have an issue where we are generating an IXOS copy for an invoice. Problem is the IXOS output and the Print preview are not same and the diffrenece is only because of some fields. 95% of the data is coming correctly. Please let us know
-
Hi everybody, There's a lot of good information coming from the experts here. It seems to me that more and more people are using the cloud to store their data. It frees up space on their hard drives. Just how safe is it? What security is available t