Query using Between for date range
Hi,
I need to list a date range of registration.. i entered
4/12/2007 (as value for form.regstart) and 7/12/2007 (as value for
form.regend)..
WHERE dateregistered BETWEEN #CreateODBCDate(form.regstart)#
AND #CreateODBCDate(form.regend)#
the result that i got was only from 4/12/2007 to 6/7/2007..
however when i run the same coding at mysql.. it works
perfectly..
any idea?
Turn on debugging and see what dates show up in the sql that
went to your db. Cold Fusion might be confused by your date format.
I certainly am.
Similar Messages
-
Use formula for date range instead of parameter?
I am designing a Crystal report that will always pull records for the next full week.
Example: Today is 8/4, so I need the report to pull data for dates 8/11 through 8/15.
Currently, I am using parameters each time to run this report.
Is there a formula that could automatically pull this date range without using parameters in my report?
Any help is appreciated.
Thanks.This is actually not too difficult. Assuming you want to be able to run this on any date and get the "Next Full Week" starting on Monday (based on your date range above), here's what you could do:
1. Create a formula that I'll call {@StartDate}
NumberVar dow := DatePart('w', CurrentDate, crMonday) - 1; //Day of week, starting on Monday.
NumberVar days := 7 - dow;
CurrentDate + days
2. Create a formula that I'll call {@EndDate}:
{@StartDate} + 7
3. In the Select Expert, manually edit the selection formula to use these date formulas instead of the parameters.
-Dell -
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 -
How to use 2 Dropdown box in webapplication for date range selection
Dear all,
I am working on a report that will show 2 drop down boxes. These should be used as a date range.
This works fine if I use 2 variables as a date range on 0CALYEAR. However I dont want the user to fill in the dates but selecting the dates with 2 drop down boxes.
I cannot manage to get this to work. I saw some comments about user exits in the forum but I cannot figure it out if there is an easier way.
Could you give me an idea of what to do?
Thanks a lot,
AndreasHi,
If you want the user to select the date directly rather than entering, you need not to have a dropdown menu in WAD. Directly go to the query which you have selected for the object in WAD, there create a variable with calendar. Put it mandatory, so that the user selection of the date will be mandatory. The variable will be automatically be available when you execute the template inn the browser.
Assign points if this helps u.
Regards,
Koundinya. -
How to use SQL to display Datethat falls between the date range
Hi,
I'm figuring out how do i use SQL to select data
that falls between the date range stated
(for eg. 19/02/1955 to 19/02/2003)
I've tried :
sql="Select * From StudentRecords WHERE DOB BETWEEN #" jTextField21.getText() "#" +" And " +"#" +jTextField22.getText;
Using BETWEEN statment , but Between Statement isn't doing what i want..
even those out of range are displayed... any ideas how??
Thank yOU in advance!oracle:
sql = "Select * From StudentRecords WHERE DOB between TO_DATE('07/04/2003','dd/mm/yyyy') and TO_DATE('08/04/2003','dd/mm/yyyy')"; -
Query to find first and last call made by selected number for date range
Hi,
query to find first and last call made by selected number for date range
according to filter:
mobile_no : 989.....
call_date_from : 25-april-2013
call_date_to : 26-april-2013
Please helpHi,
It sounds like you want a Top-N Query , something like this:
WITH got_nums AS
SELECT table_x.* -- or list columns wanted
, ROW_NUMBER () OVER (ORDER BY call_date ) AS a_num
, ROW_NUMBER () OVER (ORDER BY call_date DESC) AS d_num
FROM table_x
WHERE mobile_no = 989
AND call_date >= DATE '2013-04-25'
AND call_date < DATE '2013-04-26' + 1
SELECT * -- or list all columns except a_num and d_num
FROM got_nums
WHERE 1 IN (a_num, d_num)
;This forum is devoted to the SQL*Plus and iSQL*Plus front ends. This question doesn't have anything to do with any front end, does it? In the future, you'll get better response if you post questions like this in the PL/SQL.
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and also post the results you want from that data.
Explain, using specific examples, how you get those results from that data.
Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
See the SQL forum FAQ {message:id=9360002} -
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 -
Which BW variable is used for date(range) when creating a portal service
Hi,
Can any one please let me know which BW variable is to be used for date(range) when creating a portal service for searching based on dates.
Thanks
AbhaiHi Arun,
its just a portal service which would be called when searching a document created on a particular date or betwwen a range of date.so what i require is which BW variable to be used when handling range.As for variable technical name we use VAR_NAME_I and for single value variable we VAR_VALUE_EXT_I
in the similar manner i want BW variable to be used for range of values.
Thanks
Abhai -
Using QUERY_FIND by date range EBS-R12
HI ,
I have developed a custom form for EBS R12, and i used the standard technique to develop it,
I also used the QUERY_FIND object group to display search form. using below code in the pre-query trigger of the block
BEGIN
IF :parameter.g_query_find = 'TRUE'
THEN
COPY (:query_find.item,
'my_block.item'
:parameter.g_query_find := 'FALSE';
END IF;
END;
and everything is working fine.
but now i need to search for a DATE item, and the search should be by Date From and Date to.
I can't use the copy function to do the search for date range.
so i want to know the standard way that I should use to do such search.
I thought to used SET_BLOCK_PROPERTY and change the DEFAULT_WHERE
is this a standard way to do this search, or there is other way to do that.
Best Regards
AmirHi,
Try something like this:
SELECT grad_stu_id
FROM grad_fee_structure_hist
GROUP BY grad_stu_id
HAVING COUNT ( CASE
WHEN DATE '2010-09-01' BETWEEN grad_eff_fee_date
AND grad_exp_fee_date
THEN 1
END
) > 0
AND COUNT ( CASE
WHEN DATE '2009-09-01' BETWEEN grad_eff_fee_date
AND grad_exp_fee_date
THEN 1
END
) = 0
;If a NULL grad_fee_exp_date means that the row is currently in force, then use something like
NVL ( grad_fee_exp_date
, DATE '9999-12-31'
)instead of the raw date.
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements) and the results you want from that data. Explain how you get those results from that data, giving specific examples.
Always say what version of Oracle you're using.
Edited by: Frank Kulash on Sep 13, 2010 11:08 AM
Changed date comparisons to BETWEEN. -
I want to query based on a date range. I wrote the following EJB QL:
"select object(a) from ActionItems as a where a.dueDate
between ?1 and ?2"
But when I deployed the application to Oracle's EJB server, I got the following error:
Auto-deploying biogen.jar (No previous deployment found)... Invalid type for expression (a.dueDate BETWEEN ?1 AND ?2)
EJB QL statement : 'select object(a) from ActionItems as a where a.dueDate between ?1 and ?2'
EJB QL method : public abstract java.util.Collection ActionItemsLocalHome.findByDueDateRange(java.sql.Date,java.sql.Date) throws javax.ejb.FinderException
at com.sun.ejb.ejbql.parser.EjbQLParser.parse EjbQLParser.java:218)
at com.sun.ejb.ejbql.EjbQLDriver.parse(EjbQLDriver.java:86)
at com.sun.ejb.sqlgen.SQLGenerator.generateSQLForEjbQLQueries(SQLGenerator.java:704)
It works fine for a number range, but does not work for a date range.
Any one has an idea on how to write a correct EJB QL for a query based on date range?
Thanks.
JingzhiRe-posted. Please help!
-
Extracting a count of distinct values between two date ranges over months
Hi All,
I am having a bit of difficulty in figuring out the query to build a list of active campaigns over a date range.
i.e. I have a table with campaign IDs and their start and end date details like this
Campaign_id Start_date End_date
10001 1-Jun-09 31-May-11
10002 1-Jun-09 23-Jun-11
30041 21-Aug-09 31-Dec-09
20005 3-Jun-10 31-May-11
90021 21-Nov-09 30-Nov-10
54000 1-Jun-11 1-Dec-12
35600 1-Mar-10 31-Mar-12 What the above data means is, for eg. the campaign 10001 is active from 1-Jun-09 to 31-May-11 i.e. for 24 months (inclusive of the month Jun-09 and May-11)
What I need to figure out is the counts of active campaigns between a date range and display that active count at a month level (for e.g. lets say we want to see all the campaigns that were active
between the date range '01-JUN-2007' and '30-APR-2012' ). So the partial output would be as seen below. The list would continue till december-2012
Month Year Count of active campaigns
Jan 2009 0
Feb 2009 0
Mar 2009 0
Apr 2009 0
May 2009 0
Jun 2009 2
Jul 2009 2
Aug 2009 3
Sep 2009 3
Oct 2009 3
Nov 2009 4
Dec 2009 4
Jan 2010 3
Feb 2010 3
Mar 2010 4
Apr 2010 4
Dec 2012 1 Could anybody please help me with the right query for this.
Thanks a lot for help
Regards
Goldiset pagesize 40
with tab as
select 1 id, sysdate -100 start_date, sysdate end_date from dual
union
select 1 id, sysdate -200 start_date, sysdate -150 end_date from dual
union
select 1 id, sysdate -600 start_date, sysdate - 400 end_date from dual
union
select 1 id, sysdate -300 start_date, sysdate - 150 end_date from dual
union
select 2 id, sysdate -100 start_date, sysdate-50 end_date from dual
year_tab as
select
add_months(min_date, level -1) m
from
select min(trunc(start_date,'YYYY')) min_date, add_months(max(trunc(end_date,'YYYY')), 12) max_date
from tab
connect by level <= months_between(max_date, min_date)
select to_char(m,'YYYY') year_,
to_char(m,'Month') month_,
nvl(act, 0) act
from year_tab,
select m date_,count(*) act
from tab, year_tab
where m between trunc(start_date,'MM') and trunc(end_date,'MM')
group by m
) month_tab
where m = date_(+)
order by m;
YEAR_ MONTH_ ACT
2010 January 0
2010 February 0
2010 March 0
2010 April 0
2010 May 0
2010 June 0
2010 July 0
2010 August 0
2010 September 1
2010 October 1
2010 November 1
2010 December 1
2011 January 1
2011 February 1
2011 March 1
2011 April 0
2011 May 0
2011 June 0
2011 July 1
2011 August 1
2011 September 1
2011 October 2
2011 November 2
2011 December 2
2012 January 2
2012 February 2
2012 March 2
2012 April 1
2012 May 1
2012 June 0
2012 July 0
2012 August 0
2012 September 0
2012 October 0
2012 November 0
2012 December 0
36 rows selected. -
Im working on a report that when it is opened by end user, i want it to prompt them for a date range. The report should only show records that fall between the date ranges entered.
If i use the select expert and hardcode specific dates in, it works and only shows the records i want to see. However i cannot figure out how to set Crystal to prompt the user to enter the in DateTime and the to Date Time fields with Select Expert.
Ive tried using a Parameter field, which it prompts for the date range, but still pulls up all records as normal. Its like it ignores the date range the user enters.
The select expert shows this formula, the date/time is all zero's in this example.
{SHOP_ORD\.REVISED_START_DATE} in DateTime (0, 0, 0, 00, 00, 00) to DateTime (0, 0, 0, 00, 00, 00)
Please helpFigured it out.
Had to create two Parameter Fields {?StartDate} and {?EndDate}.
Then used Select Expert, Formula Editor to modify the formula and set the in DateTime = {?StartDate} and the to DateTime = {?EndDate}
This works. Just hide the Parameter fields and you have your range selector -
Select Between two date ranges from xml file
Hi ,
I have a column date_ with datatype VARCHAR2(150) it stores
data as
05/19/2010 11:23 AM
05/20/2010 12:23 PM
05/22/2010 11:23 AM
05/25/2010 11:23 AM
i have to select all the rows between 05/19/2010 and 05/22/2010 how to do that this column is in xml fileI have a table wit two fields
Field1 is integer and field2 is xmltype
in the xmltype i store an xml file
<ParentNode>
<Node>
<Cat>1</Cat>
<Date>05/19/2010 11:23 AM </Date>
</Node>
<Node>
<Cat>2</Cat>
<Date>05/20/2010 12:23 PM </Date>
</Node>
<Node>
<Cat>3</Cat>
<Date>05/22/2010 11:23 AM </Date>
</Node>
</Parentnode>
I am using teh below query to retrive teh result
SELECT T.Feild1, XML.* FROM Tablename T,
XMLTable( 'Parentnod/Node' PASSING T.Feild2 COLUMNS Cat NUMBER PATH 'Cat' ,
DATE_ VARCHAR2(100) PATH 'Date'
)XML where cat >1;
now i have to do teh same to select the rows between two date range 05/19/2010 and 05/21/2010
hope i am able to make teh question simple -
Hi All,
I'm facing a strange problem..
I've developed few reports. they are working fine in develop environment. after successfull testing they were published on web.
in web version, all reports are executing for first time.. if I change any of parameters values or without chaning also..
if I press "View Report" following error occurs..
An error has occurred during report processing. (rsProcessingAborted)
Query execution failed for data set 'dsMLGDB2Odbc'. (rsErrorExecutingCommand)
For more information about this error navigate to the report server on the local server machine, or enable remote errors
please suggest any alternative ways to overcome this issue
thanks in adv.in my case the problem is
one virtual machine is for developers
other for testers
in developers i created a report, then save like *.rdl and copy to testers machine, does not work there
the error what testers get is
Error during the local report processing.
Could not find a web-based application at http://developersMachine/AnalyticsReports/DataBaseConnector.rsds
and the solution is to use alternative url or in some cases http://localhost/ -
Query execution failed for data set
Hi,
We are using SQL 2005 server for generating reports.When we ran the reports it taking so much time after some time it shows this error:---
ReportProcessing.ProcessingAbortedException: An error has occurred during report processing. ---> Microsoft.ReportingServices.ReportProcessing.ReportProcessingException: Query execution failed for data set ---> System.Data.SqlClient.SqlException: A severe error occurred on the current command. The results, if any, should be discarded.
Can you help me out.
Thanks,
--AmitMy team is also facing similar problem. The RS trace logs report:
w3wp!processing!13!9/26/2007-15:31:23:: e ERROR: Throwing Microsoft.ReportingServices.ReportProcessing.ReportProcessingException: Query execution failed for data set 'msdb'., ;
Info: Microsoft.ReportingServices.ReportProcessing.ReportProcessingException: Query execution failed for data set 'msdb'. ---> System.Data.SqlClient.SqlException: A severe error occurred on the current command. The results, if any, should be discarded.
Operation cancelled by user.
In our system, Report Server and Database are on different machines. Report Server access database using a service account who has stored proc execute permissions on database.
Problem comes only if the query execution time exceeds 5 mins. Otherwise the report gets generated successfully.
I suspected this to be some timeout issue. But I have checked that all timeout settings in rs config files are as default.
Any pointers?
Thanks
puns
[email protected]
Maybe you are looking for
-
BI Webtemplate View can not be saved in Portal
Hi Friends. We are running at my Client BMW Sales Portal. in which we have used the web templates. I want to activate the functionality to save the view for reports displayed on portal. Where should I go to change any required thing in my web templat
-
HELP! animated text not showing up in final render (after effects)
I'm using position and motion blur for my animated text. I changed the font several times to see if there was any license issues and there isn't. I also put a static text layer in the file and then rendered, and THAT text will show up, but moving tex
-
BPEL Designer 10.1.2.0.2 Database Connection Error
Hi, I'm trying to create a database connection in JDeveloper 10.1.2.1.0 Build 1915 (BPEL Designer version) but I get ORA-12505, TNS:listener does not currently know of SID ... error for a particular database. I can connect to the same database using
-
Hi, When i am typing text, i can only move the cursor backward through the text using arrow keys, but not forward. The forward key does work, as pressing alt+forward scrolls forward to the end of words as it is supposed to. I don't think this is a ha
-
I have updated Adobe Flash Player and Microsoft Silverlight but each time I try to watch something I get the message that I have to install or update these programs... Why is that happening? Can it be fixed? How do I fix it? PLEASE HELP!