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,
Mohammad
Hi 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
Similar Messages
-
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 -
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 . -
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. -
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} -
Hi All,
I have requirement to write code for date range.
Characterstic = Run-Out Date, it was created reference to 0Date.
Requirement is data should load depends on Run-Out Date 7 days old and 14 days future.
Logic is -7 days old >= Run_out date <= 14 days future.
please let me know how I need to proceed with ABAP code for this requirement.
Thanks.
Please do not ask for ABAP code here. Its not a training forum
Edited by: Pravender on Aug 18, 2011 1:46 AM>
Sree vignesh wrote:
> Hi,
> In the select option we have a field month range as
> SELECT-OPTION : FROM 01.2007 TO 01.2009 " Let say Ur Selection option is SO_MONTH
> but now i need to add the DMBTR field considering the month range in the SELECT OPTION i.e., only FROM 01.2007 TO 01.2009 i mean without 2006 data.
>
> LOOP AT LT_DATA WHERE month in SO_MONTH. " Here add a Where condition
> ls_output-matnr = lt_data-belnr.
> ls_output-werks = lt_data-bukrs.
> ls_output-lgort = lt_data-dmbtr.
>
> COLLECT ls_output INTO lt_output .
>
> ENDLOOP.
>
> please help with code .
>
> thanks in advance.
Regards,
Suneel G -
Forum search doesn't seem to work for Date Range 'ALL'
Hi there,
Forum search doesn't seem to work for Date Range option: 'ALL' .
For a given search criteria, I get few search results when the date range is chosen as 'last year', but for the same search criteria, when the date range is chosen as ALL, no search results are shown (not even the ones shown earlier for last year selection).
regards,
AJCan you please delete my few duplicate replies in [CJ20n|Re: Long Text at Activity Level in CJ20N] thread?:-)
Cheers,
Amit. -
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 -
Dynamic Date Value for Date Range Parameter - Scheduling in BI
Hi,
I am New to BO Enterprise XI R3. I want to schedule the Crystal report which takes Date Range as parameter. Is any option available to calculate From Date automatically based on Current Date based on the range required?
Currently, Parameter option accepts parameters and enterprise process the report for configured parameters. In this case, report always prints only for configured date range eventhough report generated after one month. I am expecting report has to print data for date range (eg. 1 weeks, 4 days, or any range) based on system current date.
Thanks in Advance,
Venkateswaran.PI'm am in the same situation. I need to be able to have the date parameter dynamically change based on the current day's date when I schedule a report. However, because this parameter comes from a Stored Procedure from the database, it cannot be modified in the Report Designer (as far as I know). I've tried to set a default for it to use "currentdate" but it doesn't seem to take. Anyone know if this can be accomplished in the scheduler?
Thanks
-Tom -
User Prompt for Date Range in Bex Query Analyzer
I have a workbook that has two queries. The queries both require the user to enter a date range upon refresh. I want the user to be able to hit refresh, enter the date input into the dialog box and then both queries to use this date range for their input. I have seen this in other book, but when I click refresh on my book it only runs the first query. How do I get the second query to use the first queries input?
use the same variable in both the queries. this will let the user enter the date in a single variable and this will refresh both the queries.
rgds, Ghuru -
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. -
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 get Mailbox Folder Item Count for date range?
How to make query to Exchange 2013 like this:
query ItemCount (specified Mailbox, specified Folder (with subfolders), specified Date Range)?
I find this script for Exchange 2010: http://gsexdev.blogspot.ru/2012/10/item-age-sample-one-reporting-on-item.html
This script dont work for Exchange 2013 ((I believe you are making the change on both the places in code, as this path version would be different in 2013
C:\Program Files\Microsoft\Exchange\Web Services\1.2\Microsoft.Exchange.WebServices.dll"
Cheers,
Gulab Prasad
Technology Consultant
Blog:
http://www.exchangeranger.com Twitter:
LinkedIn:
Check out CodeTwo’s tools for Exchange admins
Note: Posts are provided “AS IS” without warranty of any kind, either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. -
Ms access 2007 between query for date
Dear All,
I am using the below query to fetch records from a table between two dates
select * from tablename where Format([VisitDate],"Short Date") >=Format(#01/10/2014#,"Short Date") and Format([VisitDate],"Short Date") <=Format(#31/10/2014#,"Short Date")
I want records between 1st Oct to 31st Oct only, but the above query shows Nov and December data also. Please let me know where I am going wrong.
Regards,
Noor
Thanks & Regards, Noor HussainThe Format function returns a string expression, so the comparison is on that basis not on the date value. You do not need to worry about the format at all as the date/time data type in Access is implemented as a 64 bit floating point number.
You can see it in whatever date/time format you wish, but the underlying value is always the same. When you include a date literal in an SQL statement or in VBA code it must be either in US short date format (mm/dd/yyyy), or in an internationally unambiguous
format. The ISO standard format for date notation of YYYY-MM-DD is a good choice. So you query would be:
SELECT *
FROM tablename
WHERE VisitDate >= #2014-10-01#
AND VisitDate < #2014-11-01#;
Note that the range is defined as on or after the start date and before the day following the end date. This ensures that all relevant rows are returned. As there is no such thing in Access as a 'date value', but only a 'date/time value' it is possible
that a 'date' of 31 October 2014 could have a non-zero time of day element unless you have taken steps in the table definition to specifically exclude values with a non-zero time of day. Such date/time values would not fall within a range ending <=
#2014-10-31#, so would not be returned by the query. Defining the end of the range with < #2014-11-01# ensures that such rows are returned.
Ken Sheridan, Stafford, England -
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
Maybe you are looking for
-
How can i find out if i have a bad codec affecting after effects?
hi all, i'm having all kinds of problems with after effects cs4. the current problem i'm having is i'll be working on a project, it starts to slow down and become unresponsive, i try to save but then it crashes and everything i've done is lost. openg
-
My ipod will connect to my wifi, but it cant access the internet
Okay my problem is, that my ipod touch 4th gen, will connect to my wifi, it will even have full bars, but when I try to go onto the internet, it says "Safari cannot open the page because it is not connected to the Internet." What is wrong and how do
-
Adobe Photoshop Elements Organizer 12 opens minimized in taskbar
I have a user who uses Adobe Photoshop Elements 12. It has been working fine up until a few weeks ago. Now when goes to open the Organizer, it opens up minimized down in the taskbar. When you hover over it, you can see the thumbnails of the pictur
-
Displaying a field based on the page number
I need to be able to print a field on the last page of a group. Is there any way to do this? The print on last page only option does not do what I need. Thanks
-
Why firefox keep crashing every 5 min on my android tablet?
why firefox keep crashing every 5 min on my android tablet?