Query Based on Date & Time Range
Hello Users,
There is a requirement to display weekly report from saturday 8:00 AM to previous saturday 08:00 AM.
I have a table "Downtime"
IPADDRESS First Occurrence Last Occurrence Downtime
172.29.10.12 31-JUL-10 08:12:50 01-AUG-10 09:00:00 1
172.29.11.54 01-AUG-10 11:12:00 01-AUG-10 01:10:00 3
172.29.58.7 07-AUG-10 04:10:00 07-AUG-10 05:00:00 2I will not have problem when I run the report on saturday as I can give condition as sysdate - 7.
First problem is how will I default to 8 AM.
Second if the report is run on sunday or in between before next saturdya I have to query the records only from satuday 8 AM to previous saturday 8 AM.
Can anyone please help me on this?
Thanks.
Ravi.
Hi,
hoek wrote:
That's a great hint, Solomon, thanks.
I always end up getting frustrated because trunc on a date returns a NULL for 'midnight'....and the ability to perform date arithmetic is gone all of a sudden. Why isn't Oracle just resetting to '00:00:00' when truncating a date, I wonder?I must not understand what you're asking.
It sounds as if you're saying that TRUNC (dt) sometimes returns something that is NULL (or somehow partially NULL), but I'm sure you don't really think that.
For other readers who may be wondering:
TRUNC (dt), where dt is a DATE (and not NULL) , always returns a DATE, and DATEs always have a time. Either the whole DATE is NULL or none of it is; you can't have a year-month-day in a DATE column and not have a time, or have a NULL time.
TRUNC(dt, x) may return a DATE where the time is not midnight, but only if x is a format string like 'MI' that specifies an interval less than a day. When x indicates a longer interval (e,g, 'IW'), or when x is omitted, the time is always midnight. In any event, you can do date arithmetic on the results.
I'm sure you understand this, but your question makes it sound like you don't.
This should illustrate my point:
-- generating hours, starting 14 days ago:
with t as (
select trunc(sysdate-14)+ level/24-1 dt
from dual
connect by level <= 24*14
-- querying generated data:
select dt
--, trunc(dt,'iw') - 5/3 -- great workaround, but why can't we just work with 00:00:00 for the time component?
from t;
-- generating hours, starting 14 days ago:
with t as (
select trunc(sysdate-14)+ level/24-1 dt
from dual
connect by level <= 24*14
-- querying data between saturday and previous saturday
-- from the same resultset and 'it doesn't work'
select dt
from t
where dt between trunc(dt-7)+8/24 and trunc(sysdate)+8/24;
Is this a parody of a poorly written question?
Are you trying to make the point that no one should ever say "it doesn't work" without explaining exactly what doesn't work, and what the expected output is?
I get the same 336 rows when I run either of the queries above.
As you've often said, posters should always show exactly what results they want.
Similar Messages
-
Is it possible to get the updated table records based on date & time.
Is it possible to get the updated table records based on date & time in oracle.
Thanks in advance.no, actually i am asking update records using 'UPDATE
or DELETE' statement, but not insert statement.
Is it possible?
I think we can do using trigger on table, but problem
is if i am having 20 tables means i have to write 20
trigger. i don't want like this.Of course it's still possible, typically you'll find applications with a column LAST_UPDATE, probably a LAST_UPDATED_BY and so on column. You don't say what your business need is, if you just want a one of query of updates to particular records and have a recent version of Oracle, then flashback query may well help, if you want to record update timestamps you either have to modify the table, or write some code to store your updates in an audit table somewhere.
Niall Litchfield
http://www.orawin.info/ -
Datalogging with options to retrieve subset of log file based on date/time
I would like to thank this forum for useful advice so far in completing my LabVIEW software.
I have a data logging challenge. I am supposed to log about 30 parameters every 5 seconds. Some of these parameters are digital (ON/OFF), some are values of speed (rpm) and others, an expression of a percentage (%). It should be possible in future to do a histogram or bar chart plot of some of the parameters, for a specific period range (say the last 5 minutes of a certain day). So in effect, do an extraction of a segment of the total log file.
My challenge is if I use text file, like the one in the attached VI, can it give functionality of retrieving data (while the VI is running) from the log file, based on a certain time range (i.e. retrieve a section of the log file based on a certain date/time range, on demand)?
The format in the text file is close to what I require, since it lists the time n one column and the other parameters on other columns to enable future histogram generation.
Thanks a lot, friends.
Solved!
Go to Solution.
Attachments:
writer.vi 19 KB
time.txt 1 KBHey maxidivine,
Iv been playing round with your code and found that to perform the search that you require could be quite demanding to system resources when scaled to the size of your application I shall try and find a way to perform the search using .txt files but the there are some other options available. I recommend the use if TDMS files as the file format is a very efficient, manageable method of data-logging. The TDMS file format is designed to write and read measured data at a very high speed, while maintaining a hierarchical system of descriptive information.
Traditionally, TDMS was a National Instruments only file format – you could only read it using our products – LabVIEW/CVI/DIAdem. However, thanks to the popularity of the format, a bolt-on is now available for Excel, which allows you to directly open the .tdms files with Excel (see link).
National Instruments Technical Data Management Overview
http://zone.ni.com/devzone/cda/tut/p/id/3676
Introduction to LabVIEW TDM Streaming Vis
http://zone.ni.com/devzone/cda/tut/p/id/3539
VI-Based API for Writing TDMS Files
http://zone.ni.com/devzone/cda/tut/p/id/6471
TDM Excel Add-In Tool for Microsoft Excel User Guide
http://zone.ni.com/devzone/cda/tut/p/id/4906
TDM Excel Add-In for Microsoft Excel Download
http://zone.ni.com/devzone/cda/epd/p/id/2944
Troubleshooting the TDM Excel Add-In for Microsoft Excel 2000-2003
http://zone.ni.com/devzone/cda/tut/p/id/5874
Examples of the use of the TDMS API ship with LabVIEW. You will find them in HELP > find examples > fundamentals > File Input and Output. For you application, I would recommend the “Cont Acq&Graph Voltage - Write Data to File (TDMS).vi”.
Furthermore, if you require some help with DIAdem, I would recommend clicking "getting started" from the DIAdem splash screen. This opens a manual which discusses everything from data analysis to report generation. Also, if you have DIAdem 11 or above, there are tutorial videos which install with DIAdem. These are useful little tutorials, which discuss all the DIAdem fundamentals. You can access these by selecting a particular palette tab (eg. report, view, analysis...etc) and then clicking the tutorial button (shown as a film strip with a question mark) at the top of the group view.
Here are some more helpful DIAdem related resources for future reference.
Report Gen in DIAdem...
http://zone.ni.com/devzone/cda/tut/p/id/7379
DataPlugins: Supported Data Formats (ni.com/dataplugins)
http://zone.ni.com/devzone/cda/tut/p/id/4065
Hope this is helpful
Philip
Philip
Applications Engineer
National Instruments
UK Branch
===If this fixes your problem, mark as solution!=== -
Collapsing rows - date/time ranges
Hi,
I need to collapse date/time ranges (1 range per row) into the smallest continuous block for a particular item, instance (date/time).
For example,
CREATE TABLE "BLOCK_TEST"
"ID" NUMBER,
"START_BLK" DATE,
"STOP_BLK" DATE
alter session set nls_date_format = "YYYY-MM-DD HH24:MI";
INSERT INTO BLOCK_TEST ("ID","START_BLK","STOP_BLK") VALUES (1, TO_DATE('2006-07-03 01:00'), TO_DATE('2006-07-03 01:30'));
INSERT INTO BLOCK_TEST ("ID","START_BLK","STOP_BLK") VALUES (1, TO_DATE('2006-07-03 01:30'), TO_DATE('2006-07-03 02:00'));
INSERT INTO BLOCK_TEST ("ID","START_BLK","STOP_BLK") VALUES (1, TO_DATE('2006-07-03 02:00'), TO_DATE('2006-07-03 02:30'));
INSERT INTO BLOCK_TEST ("ID","START_BLK","STOP_BLK") VALUES (1, TO_DATE('2006-07-03 02:30'), TO_DATE('2006-07-03 03:00'));
INSERT INTO BLOCK_TEST ("ID","START_BLK","STOP_BLK") VALUES (1, TO_DATE('2006-07-03 03:30'), TO_DATE('2006-07-03 04:00'));
INSERT INTO BLOCK_TEST ("ID","START_BLK","STOP_BLK") VALUES (1, TO_DATE('2006-07-03 04:00'), TO_DATE('2006-07-03 04:30'));
INSERT INTO BLOCK_TEST ("ID","START_BLK","STOP_BLK") VALUES (2, TO_DATE('2006-07-03 02:00'), TO_DATE('2006-07-03 02:30'));
INSERT INTO BLOCK_TEST ("ID","START_BLK","STOP_BLK") VALUES (2, TO_DATE('2006-07-03 02:30'), TO_DATE('2006-07-03 03:00'));
INSERT INTO BLOCK_TEST ("ID","START_BLK","STOP_BLK") VALUES (2, TO_DATE('2006-07-03 03:00'), TO_DATE('2006-07-03 03:30'));
select * from block_test order by id, start_blk;
ID START_BLK STOP_BLK
1 2006-07-03 01:00 2006-07-03 01:30
1 2006-07-03 01:30 2006-07-03 02:00
1 2006-07-03 02:00 2006-07-03 02:30
1 2006-07-03 02:30 2006-07-03 03:00
1 2006-07-03 03:30 2006-07-03 04:00
1 2006-07-03 04:00 2006-07-03 04:30
2 2006-07-03 02:00 2006-07-03 02:30
2 2006-07-03 02:30 2006-07-03 03:00
2 2006-07-03 03:00 2006-07-03 03:30If ID = 1 and my instance is 2006-07-03 01:45, I need to obtain 2006-07-03 01:00 as the start of the block and 2006-07-03 03:00 as the end - notice the gap from 3:00 to 3:30 so the end would not be 4:30.
I can do this in a procedure but I was wondering if this could be done with just SQL?
Any hints, suggestions or opinions would be welcome.
Thanks,
dfg
EDIT: After re-reading this, need to clarify that I don't need to actually change or update the rows, just query to get the start and end of the block in question...
Message was edited by:
IndyThere might be better ways but the following worked for me
SQL> select
2 first_value(start_blk) over (partition by id ORDER BY lvl desc),
3 first_value(stop_blk) over (partition by id ORDER BY lvl desc)
4 from (select level lvl, id, connect_by_root start_blk start_blk, stop_blk
5 from (select id , start_blk, stop_blk
6 from block_test
7 where id=1
8 )
9 connect by prior stop_blk=start_blk
10 order by level desc
11 )
12 where to_date('2006-07-03 01:45', 'YYYY-MM-DD HH24:MI') between start_blk and stop_blk
13 and rownum < 2
14 ;
FIRST_VALUE(STAR FIRST_VALUE(STOP
2006-07-03 01:00 2006-07-03 03:00
SQL> select
2 first_value(start_blk) over (partition by id ORDER BY lvl desc),
3 first_value(stop_blk) over (partition by id ORDER BY lvl desc)
4 from (select level lvl, id, connect_by_root start_blk start_blk, stop_blk
5 from (select id , start_blk, stop_blk
6 from block_test
7 where id=1
8 )
9 connect by prior stop_blk=start_blk
10 order by level desc
11 )
12 where to_date('2006-07-03 03:15', 'YYYY-MM-DD HH24:MI') between start_blk and stop_blk
13 and rownum < 2
14 ;
no rows selected
SQL> select
2 first_value(start_blk) over (partition by id ORDER BY lvl desc),
3 first_value(stop_blk) over (partition by id ORDER BY lvl desc)
4 from (select level lvl, id, connect_by_root start_blk start_blk, stop_blk
5 from (select id , start_blk, stop_blk
6 from block_test
7 where id=1
8 )
9 connect by prior stop_blk=start_blk
10 order by level desc
11 )
12 where to_date('2006-07-03 03:45', 'YYYY-MM-DD HH24:MI') between start_blk and stop_blk
13 and rownum < 2
14 ;
FIRST_VALUE(STAR FIRST_VALUE(STOP
2006-07-03 03:30 2006-07-03 04:30
SQL> -
Hi,
I am trying to output only a successful job during the past 24 hrs of each day. If there is job that has an outcome of a success and a failure within the last
24 hrs for each day, I want to only output the successful one. If there are no success for the same job, I will output the last attempted failed job.
Here are my columns:
current output:
JOB_ID JOBDATE GROUP PATH OUTCOME FAILED LEVEL ASSET
3400908 7/27/2012 10:01:18 AM polA target1 Success 0 incr clone1
3400907 7/27/2012 10:01:09 AM polA target1 Failed 0 incr clone1
3389180 7/23/2012 10:01:14 AM polA target1 Failed 1 incr clone1
3374713 7/23/2012 10:01:03 AM polA target1 Success 0 incr clone1
3374712 7/22/2012 11:24:32 AM polA target1 Success 0 Full clone1
3367074 7/22/2012 11:24:00 AM polA target1 Failed 1 Full clone1
3167074 7/21/2012 10:01:13 AM polA target1 Success 0 incr clone1
336074 7/21/2012 10:01:08 AM polA target1 Success 0 incr clone1
desired output:
JOB_ID JOBDATE GROUP PATH OUTCOME FAILED LEVEL ASSET
3400908 7/27/2012 10:01:18 AM polA target1 Success 0 incr clone1
3374713 7/23/2012 10:01:03 AM polA target1 Success 0 incr clone1
3374712 7/22/2012 11:24:32 AM polA target1 Success 0 Full clone1
3167074 7/21/2012 10:01:13 AM polA target1 Success 0 incr clone1
Here is a code I am trying to use without success:
select *
from
(selectjob_id, jobdate, group, path, outcome, Failed, level, asset,
ROW_NUMBER() OVER(PARTITION BY group, path, asset ORDER BY jobdate desc) as rn
from job_table where jobdate between trunc(jobdate) and trunc(jobdate) -1 )
where rn = 1
order by jobdate desc;Thanks,
-AbeHi, Abe,
You're on the right track, using ROW_NUMBER to assign numbers, and picking only #1 in the main query. The main thing you're missing is the PARTITION BY clause.
You want to assign a #1 for each distinct combination of group_id, path, asset and calendar day , right?
Then you need to PARTITION BY group_id, path, asset and calendar day . I think you realized that when you named this thread "Query Based *on date partition* ".
The next thing is the analytic ORDER BY clause. To see which row in each partition gets assigned #1, you need to order the rows by outcome ('Success' first, then 'Failed'), and after that, by jobdate (latest jobdate first, which is DESCending order).
If so, this is what you want:
WITH got_r_num AS
SELECT j.* -- or list columns wanted
, ROW_NUMBER () OVER ( PARTITION BY group_id -- GROUP is not a good column name
, path
, asset
, TRUNC (jobdate)
ORDER BY CASE outcome
WHEN 'Succcess'
THEN 1
ELSE 2
END
, jobdate DESC
) AS r_num
FROM job_table j
WHERE outcome IN ('Success', 'Failed')
-- AND ... -- Any other filtering, if needed
SELECT * -- or list all columns except r_num
FROM got_r_num
WHERE r_num = 1
;If you'd care to post CREATE TABLE and INSERT statements for the sample data, then I could test it.
It looks like you posted multiple copies of this thread. I'll bet that's not your fault; this site can cause that. Even though it's not your fault, please mark all the duplicate versions of this thread as "Answered" right away, and continue in this thread if necessary.
Edited by: Frank Kulash on Jul 28, 2012 11:47 PM
This site is flakier than I thought! I did see at least 3 copies of this same thread earlier, but I don't see them now. -
Select Query Based on date condition
Hi ,
Is it Possible.
i want to run select query based on date condition.
Eg...
if the date between 01-jan-01 and 01-jan-05 then
select * from table1;
if the date between 02-jan-05 and 01-jan-08 then
select * from table2;
Becaz i have data in 2 diffrent tables , based on the date condition i wnt to run the select statement to diffrent tables.
i dont want plsql here Just SQL needed.
thanks,
-R
Edited by: infant_raj on May 5, 2009 11:48 PMHelo Kanish,
this is not the one i was asking..
wht i mean was .
i use bind variable to get date while running the select statement , once i get the date then i want to choose any one of the table to run select query.
EG..
select col1,col2 from table1 where date between only if 01-jan-01 and 01-jan-05;
select col1,col2 from table2 where date between only if 02-jan-05 and 01-jan-08;
Run any one of the two . not all
thanks,
_raj -
Have you guys ever tried to write a query based on CMP?
The EJB QL is:
select object(a) from ActionItems as a where a.duedate = ?1
When I deployed it to OC4J, I got the following error:
Error compiling D:\oc4j903\j2ee\home\applications\biogen/biogen.jar: Error trans
lating EJBQL: Invalid type for expression (a.dueDate = ?1)
EJB QL statement : 'select object(a) from ActionItems as a where a.dueDate = ?1'
EJB QL method : public abstract java.util.Collection ActionItemsLocalHome.findByDueDate(java.sql.Date) throws javax.ejb.FinderException
Auto-deploying file:/D:/oc4j903/j2ee/home/applications/biogen/biogen/ (Assembly
had been updated)...
So, any query that is based on date will not work for OC4J, is this a bug or what?
Thanks for the reply.
JingzhiI would post this question (and your date range question) to the J2EE group. More J2EE/EJB specific questions are answered there.
To my understanding the standard ejb2.0 specification is weak in date comparisons for queries. I believe you need to add your date queries to your application server specific orion-ejb-jar.xml file. I'm not sure of how, I would post that question to the J2EE forum, or look it up in the 9ias documentation.
-Mark -
Aperture 3.2: renaming based on date/time doesn't work properly
While importing I rename my photos based on the date/time they were taken.
In Aperture 3.1.3 this worked perfectly fine; for photos taken within the same second Aperture added an index number for the second, third etc. photo automatically.
In Aperture 3.2 this doesn't work any longer; Aperture simply doesn't import photo number 2, 3 etc. of that particular one second.
Note: I store the original files outside the aperture library, all run under snow leopard on an iMac i7. And as I said this worked fine under 3.1.
Does anyone have an idea?Thanks all for the response
Leonie, here are the details of what I do/experience:
a) Aperture message after import
b) I import pairs and rename them as follows “IMG_{Image Date}_{Image_Time}” (I know all the disadvantages of this but old habits are hard to break… and for me it still works fine)
c) Difference of the images that are imported / not imported is solely the hundredth of the second when they were taken. Of my test series only the first image has been imported:
DSC_4903.jpg(2011/10/19 22:49:50.08)
DSC_4904.jpg(2011/10/19 22:49:50.25)
DSC_4905.jpg(2011/10/19 22:49:50.43)
DSC_4906.jpg(2011/10/19 22:49:50.60)
DSC_4907.jpg(2011/10/19 22:49:50.80)
d) I import via the import panel: Import in new project – storefiles in particular folder (not Aperture library) – subfolder ‘imageyear/month” – rename as described above – import both
Doug, after some trial and error I agree with your thoughts, Aperture apparently simply lost its automatic indexes ‘-1’, ‘-2’ etc. and – what is good - doesn’t overwrite the first with the second and the third image... As you suggest there are different options to make the images unique. Most simple would be to add {index #} or {sequence #} or {counter}, all would do and I probably will choose one of them. Or I will downgrade back to 3.1.3 (do have backups) and wait until Apple fixes this.
Kirby, turnoff “Don’t import duplicates” was a good idea but didn’t solve it. But your naming convention actually ensures the uniqueness of the files.
Michael -
I am new to scripting (literally started reading/learning scripting a few hours ago), and I am stuck in trying to get my current script/command to filter a specific date range.
* Note: I am working with Server 2003 and 2008; because of the environment I am in, a lot of scripts (such as Powershell and VBScript) don't work; trying to stick with command line, as it appears to be the only thing that functions correctly in my environment
I am trying to search the System log in event viewer, for the most recent server reboot. Here is the command that I am currently running:
===========================================================
C:\Windows\System32\cscript C:\Windows\System32\eventquery.vbs /L System /FI "id eq 1074"
===========================================================
When run, the output looks like this:
===========================================================
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved
Listing the events in 'system' log of host 'xxxxxxxxxxxxxxx'
Type Event
Date Time Source
Information 1074
12/18/2013 2:48:06 AM USER32
Information 1074
11/20/2013 3:25:04 AM USER32
Information 1074
10/23/2013 2:06:09 AM USER32
===========================================================
What I would like it to do is only show events that have happened in the last seven days, as well as show the event details if it does find an event that matches the criteria.
Any help would be greatly appreciated. Thanks!
NickI would prefer using Powershell , you can use below code
function Get-EventViewer
param(
[string[]]$ComputerName = $ENV:COMPUTERNAME,[string]$LogName,[int]$eventid
$Object =@()
foreach ($Computer in $ComputerName)
$ApplicationEvents = get-eventlog -logname $LogName -cn $computer -after (Get-Date).AddDays(-7) | ?{$_.eventid -eq "$eventid" }
foreach ($event in $ApplicationEvents) {
$Object += New-Object -Type PSObject -Property @{
ComputerName = $Computer.ToUpper();
TimeGenerated = $event.TimeGenerated;
EntryType = $event.EntryType;
Source = $event.Source;
Message = $event.Message;
$column1 = @{expression="ComputerName"; width=12; label="ComputerName"; alignment="left"}
$column2 = @{expression="TimeGenerated"; width=22; label="TimeGenerated"; alignment="left"}
$column3 = @{expression="EntryType"; width=10; label="EntryType"; alignment="left"}
$column4 = @{expression="Source"; width=15; label="Source"; alignment="left"}
$column5 = @{expression="Message"; width=100; label="Message"; alignment="left"}
$Object|format-table $column1, $column2, $column3 ,$column4 ,$column5
$Object.GetEnumerator() | Out-GridView -Title "Event Viewer"
You can do a function call like
Get-EventViewer -LogName system -ComputerName "computername" -eventid "2017" -
Creating iCal entries based on date/time appearing in text on any app
One thing I like about iCal's integration with Apple Mail is that the mail client is able to sense dates and times in email messages and then allow you to create iCal entries. But it seems that this date and time sensing is only limited to Apple Mail when technically users could potentially want to create iCal entries when a date and time appears on any app, such as on a web page in a web browser, in a PDF, or a word processing document. It seems logical then for iCal to be integrated with OS X's text services, so that at least if I highlighted a date and time, I could right click on it and bring up an option to create an iCal entry on based on that date and time.
Does anyone know if this feature is natively supported (for which I have yet to enable), or is there a third party app out there that will allow me to do this?Just a quick update. I tried the first two -- text2cal and Calendar Creator -- and they don't seem to work on OS X 10.6.6.
However, on another note, I found some discussion regarding Snow Leopard's enhanced data detectors being natively able to do what I've been looking for. But I just can't seem to get it to work on my computer:
"Enhanced Data Detectors now link dates, times and other items found in text to actionable items in other applications, like iCal. For example, a drop-down menu that automatically appears when you select the time or date parts in a text enables you to create a new iCal event from a selected date or show the date in iCal." From this link: http://www.geek.com/articles/chips/5-cool-snow-leopard-features-that-apple-doesn t-want-you-to-see-yet-20090520/ -
Auto-expire from query based on date
I have some records in my MySQL db that contain dates for upcoming events.. I need a way to query upcoming events and expire them from the query once the date passes without necessarily deleting them from the database. (I'm publishing the next 5 upcoming events to the homepage via 'LIMIT 5').
Is there an easy way to do this within a MySQL db query? This section of the site (both insert record, display, current query, etc) is all created with ADDT.
Please let me know!
Thanks!Hi Nathan,
I reckon you´d just need to display those events which come later than what MySQL calls "CURDATE()"
(aka "current date") -- so a query like...
SELECT * FROM tablename WHERE CURDATE() > 'datefield'
...should filter the past dates. Works ??
Cheers,
Günter Schenk
Adobe Community Expert, Dreamweaver -
Date / Time Range Selection
Post Author: LDFCC
CA Forum: Formula
I am trying to create a report using Crystal Report XI which prompts the user to enter a start date / end date / start time & end time. For example, the person will select 9/19 (start date), 9/20 (end date), 10 AM (Start time), 10:30 AM (End Time). The report correctly pull up all tickets from 9/19 till 9/20 but only displays the tickets from 9/19 from 10 - 10:30 AM and 9/20 from 10 - 10:30 AM. I need it to show all tickets from 9/19 10:00 AM till 9/20 10:30 AM. Both the time and date are two seperate fields in the database. Any help is greatly appreciated.
Thanks.Post Author: LDFCC
CA Forum: Formula
yangster:
since you are dealing with 2 seperate fields for date and time the first thing you want to do is merge them back into one so things are consistenttry putting this in your selection expert
datetimevar begin_date_time := datetime(cdate(?begin date), ctime(?begin time));datetimevar end_date_time := datetime(cdate(?end date), ctime(?end time));datetime(cdate(date_field), ctime(time_field)) in begin_date_time to end_date_time
I tried this and I get an error because it says that (?begin date), (?begin time), (?end time), and (?end date) all have to be date time fields but they are not the date field is only date field and same with the time fields. Any suggestions? -
How to select data, based on a specified or preset date/time range
Hi,
I am trying to construct a requirement like this in java/jsp.
I have a table consisting of registered users info. Have a expiration date for every user, which was captured or set when they originally registered.
I have to select all those users who are expiring two weeks from now.
For example. if the current date is 14th, I should get a list of users who expire between the midnight of 24th sunday to 30th saturday. this covers the whole last 7days in that range. And so on.
So based on the current date, the last midnight sunday to midnight saturday of that two week's range should be selected.
The input fields for this range on the userend should default to this range.
And also the user should be able to specify their own range and be able to pull data.
the result should be populated as viewable as well as a downloadable tab de-limited file for mass mailing.
(ex. the table might be queried for user info like id, email, expiration date, fullname, and shown accordingly in the jsp)
I know this is a longshot.. but if somebody can guide me will be good as I am new to this forum and as well as java.Well, I can start you off with this:
Calendar now = Calendar.getInstance();
// shift 2 weeks and back to Sunday
Calendar start = Calendar.getInstance();
start.add(Calendar.DATE, 14);
end.set(Calendar.HOUR, 0);
end.set(Calendar.MINUTE, 0);
end.set(Calendar.SECOND, 0);
end.set(Calendar.MILLISECOND, 0);
while(start.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY) {
start.add(Calendar.DATE, -1);
// shift 2 weeks and up to Saturday (following Sundat midnight, actually)
Calendar end = Calendar.getInstance();
end.add(Calendar.DATE, 14);
end.set(Calendar.HOUR, 0);
end.set(Calendar.MINUTE, 0);
end.set(Calendar.SECOND, 0);
end.set(Calendar.MILLISECOND, 0);
while(end.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY) {
end.add(Calendar.DATE, -1);
At this point, start is the first Sunday before the day 2 weeks from today and end is the first Sunday after the day 2 weeks from today, both at midnight. You could make end stop at Saturday and make the time 23:59:59:999, of course.
If you ran it today, it should be 11/9 and 11/16. -
Query Designer Master data Time Dependent
Hello
im with this problem
i have master data:
material/till/since/price/description
1/14.01.2010/01.01.1000/20/Material1-old
1/31.12.2010/13.01.2010/15/Material-new
cube:
material/date/quantity
1/01.01.2010/5
1/15.01.2010/20
in my querty designer, i put the 0calday with selection options
when i insert for example 01.01.2010
its couting the "material-new" ( 15*5) it shoudlnt
it should calculate the old one. (20*5)
how can i fix it?
regards,Hi Amit,
At "Query properties" screen, you can define a "Key date". It can be fixed or it can be calculated from a user-input variable. If you do not specify one, the default key date value is the date on which the query is executed (today).
For time-dependent data, the key date determines the time for which the data is selected (material price, in your case). However, there is only one key date per query. You can't make it dynamic depending on the value of 0CALDAY in every transactional data record.
Perhaps you might consider the option of adding 0AMOUNT to your InfoCube, and precalculate the formula quantity*price using an ABAP routine which reads price from InfoObject Q table, filtering by OBJVERS='A' and DATETO/DATEFROM=0CALDAY.
I hope this helps you.
Regards,
Maximiliano -
Hi,
There are two :p1_start and :p2_end bind variable
If the above two bind variables are null it must show all the data.
if two bind variables are not null then it will show the dates between two date pickers.
select actual_end,status from schedule
where
actual_end is between to_date(:p1_start) and to_date(:p1_end)
Please suggest me in modifying the query.
Thanks
SudhirI disagree with using notional start and end dates and agree with Roel that the column should be equated to itself instead.
However using NVL may negate the index on the column, so I would suggest this instead (logically its the same as Roel's suggestion though)...
SELECT *
FROM my_table
WHERE date_col BETWEEN CASE WHEN TO_DATE(:P_STARTDATE) IS NULL
THEN date_col
ELSE TO_DATE(:P_STARTDATE)
END
AND
CASE WHEN TO_DATE(:P_ENDDATE) IS NULL
THEN date_col
ELSE TO_DATE(:P_ENDDATE)
ENDCheers
Ben
Maybe you are looking for
-
Hello My system version 10.5.8 I have installed Safari update - 5.0.6 and the browser stopped working. At openingit shows the following icon: "Safari has suddenly finished working. Possible problem is in the action of the plugin "TastyAppsAVPlugin".
-
Time Machine - Can't Explore Previous Backups, Can't Open Image!
I have a two-fold problem with my Time Machine. 1. I plugged in my USB hard drive into my Macbook Pro, and let it backup. Then, I plugged it into an Airport Extreme n (Fast Ethernet) and it resumed the backups successfully. But, regardless of whether
-
had to buy a new laptop and am trying to install XI (current and active licensee)....registration setup screen indicates ("Invalid Serial Number")? Account is active.
-
Create from acrobat x standard fails worked with 9 pro.
So we have an older app (delphi 6) that worked fine to create pdf with acrobat 9 pro. the user updated to windows 7 machine and got acrobat X standard and so now it fails to pop up the dialog to name the file. As tho it gets hung. So the helpless lit
-
Setting time in adf-faces-config.xml configuration file
Hello check this link http://jdevadf.oracle.com/adf-richclient-demo/docs/tagdoc/af_convertDateTime.html this specifies "Timezone can be set per web-app in adf-faces-config.xml configuration file. If timeZone is not set on the converter, then timezone