SQL & PL/SQL :: Converting Dates - How To Compare Data With Sysdate And Display

Jan 5, 2011

CREATE TABLE SCHEDULE_DETAILS
(
SCHEDULE_ID NUMBER NOT NULL,
SCHEDULE_TYPE VARCHAR2(10 BYTE),
SCHEDULE_START_DATE DATE,
SCHEDULE_END_DATE DATE,
RUNTIME CHAR(8 BYTE),
TIMEZONE VARCHAR2(40 BYTE));

SET DEFINE OFF;
Insert into SCHEDULE_DETAILS
(SCHEDULE_ID, SCHEDULE_TYPE, SCHEDULE_START_DATE, SCHEDULE_END_DATE, RUNTIME, TIMEZONE)
Values
(1970, 'Daily', TO_DATE('07/26/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'),
TO_DATE('01/26/2011 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), '13:58 ', 'America/New_York');
[code]........

Taking Today date and timezone as EST, I need to run a select that shows all the rows , where sysdate falls in between

Start_date and End_date and RunTime, ( run time is basically the Local time of the TimeZone Column)

Basically we should Display rows by checking/Converting, Start_date||End_date||Runtime||timezone with Sysdate(est) then display.

From the Above Data these rows should be Displayed by that select, how to compare this data with sysdate and display.

SCHEDULE_IDSCHEDULE_TYPESCHEDULE_START_DATESCHEDULE_END_DATERUNTIMETIMEZONE
1970Daily7/26/20101/26/201113:58 America/New_York
2588Daily10/18/20104/18/201115:50 America/New_York
3567Daily12/8/20106/8/20118:40 America/New_York
3386Daily12/27/20106/27/20111:0 America/New_York
1973Daily8/3/20102/3/201111:25 America/New_York
2565Daily9/7/20103/7/20117:0 America/New_York
3580Daily12/20/20106/20/201117:0 America/Chicago
3167Daily11/30/20105/30/20111:0 US/Alaska
3390Daily12/30/20101/15/20117:00 Asia/Calcutta

For Example, Below rows shouldn't come, Since it's end date is less than Sysdate.

SCHEDULE_IDSCHEDULE_TYPESCHEDULE_START_DATESCHEDULE_END_DATERUNTIMETIMEZONE
2579Daily9/17/20109/18/201011:32 America/New_York

View 2 Replies


ADVERTISEMENT

Compare A Date In One Of Tables To Sysdate?

Mar 5, 2012

i wanted to compare a date in one of my tables to sysdate. I have a table reservation and a field in it is Date Reserved From, i wanted to compare this to sysdate and returned the results

View 2 Replies View Related

Creating A Trigger To Compare Dates

Mar 22, 2007

I've been assigned a task at work that consists of creating a trigger on a table. This table is used to store temporary query results. I'm trying to make a trigger to clean the table so old results don't accumulate.

There is a column named DATE_UPDATED that stores an Oracle Date for when the row was inserted/updated. If the row is not updated in 12 hours, I want to delete it.

Here is what I have so far.

CREATE OR REPLACE TRIGGER clean_tableName
AFTER INSERT OR UPDATE
ON tableName

BEGIN

END clean_tableName;

As you can see, I don't have an actual function body yet. What would be the best way to accomplish this? Should I declare a variable to store the current Date+12 hours and then just compare that in a delete statement?

I'm thinking something like:

DECLARE
laterDate DATE := SYSDATE+12; // Not sure how to add 12 hours to a date.
BEGIN
DELETE FROM tableName WHERE DATE_UPDATED > laterDate;
END clean_tableName;

But I'm not sure how to add 12 hours to the current date. Is there a way I can do this without defining a variable?

View 2 Replies View Related

SQL & PL/SQL :: Forms 6i - Compare Start And End Dates

Feb 6, 2011

I am comparing the dates in forms 6i.I need to compare the start and end dates and if the date are getting than an year then i need to get an error message.

View 2 Replies View Related

Forms :: Cannot Display Sysdate In Oracle

Mar 8, 2013

when i open my oracle form on my live application server to display sysdate its does not show me.but when i open this same form on my test application server its shows my current sysdate time.

View 1 Replies View Related

Forms :: Display Sysdate And User On Item Form

Aug 7, 2010

query also a button click the trigger used when button press event user then the write this query.

SELECT USER INTO :BLOCK3.DISPLAY_ITEM7 FROM DUAL;

View 7 Replies View Related

SQL & PL/SQL :: Display All The Months Between Two Dates?

Aug 17, 2010

I have this same problem and still i am getting one error message

ORA-00933: SQL command not properly ended

and the code in highlighted in 'by'

'from test_case partition by'

View 6 Replies View Related

SQL & PL/SQL :: Query To Display Next Ten Dates

Apr 28, 2010

When i had a interview last week they ask me to write a query to display the next ten dates using sql query ( without using PL/SQL).

View 11 Replies View Related

Dates In Sql - Display Name And Next Birthday

Nov 13, 2010

Heres the first question:

Use a select statement with a subquery to display the names of all departments that are responsible for at least one project that has already started.

Heres are the 2 relations:

DEPT(Department table)

COLUMN TYPE SIZE
DEPTNO CHAR 3
DEPTNAME VARCHAR 36

PROJ(Project Table)

COLUMN TYPE SIZE
PROJNAME VARCHAR 24
DEPTNO CHAR 3
STARTDATE DATE

The second question :

For every employee whose birthday falls between now and the end of this year, display the name and next birthday.

Here is the relation:
COLUMN TYPE SIZE
NAME VARCHAR 12
BIRTHDATE DATE

View 3 Replies View Related

SQL & PL/SQL :: Getting Query For Current Year Data Up To Sysdate?

Jun 19, 2012

I have a table for exampl,

emp sal date
111 200 03-mar-2011
100 200 03-mar-2012
15 200 06-mar-2012
17 200 03-mar-2003
178 200 03-mar-2004
11 200 11-jun-2012
101 200 19-jun-2012

i need sql querry to get current year records upto sysdate.i.e for example this year 2012 so i need all the 2012 year records upto sysdate.

my output like this.....

emp sal date
100 200 03-mar-2012
15 200 06-mar-2012
11 200 11-jun-2012
101 200 19-jun-2012(upto sysdate)

View 2 Replies View Related

SQL & PL/SQL :: Converting XLS With Korean Data To CSV And Reading It

Mar 3, 2011

oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
PL/SQL Release 11.1.0.6.0 - Production
"CORE 11.1.0.6.0 Production"

I have a .xls file, which has few columns with Korean data. I have problem converting it into .csv. I converted it to UNICODE TEXT, which was TAB separated. I replaced tabs with commas. but still saved it as .txt file. Now I am using utl_file package to open and read.

utl_file.fopen_nchar(l_dir, l_filename , 'R',8000);

I outputted the first header line, and instead of Korean fieldnames, it displayed some different characters.. cannot even copy-paste..

I am uploading the converted .txt as I cannot upload original .xls file here...

View 18 Replies View Related

SQL & PL/SQL :: Converting Data From English To Arabic?

Feb 1, 2012

I need to prepare a bilingual system (English and Arabic).

So i need to store data in English as well as in Arabic

Is there any possibility to convert the data from English to Arabic and Arabic to English through oracle forms

basically what i am thinking is let us suppose user selected the English version of the application and he entered all the data in English during saving the records i need to convert all the English data into Arabic and store it in another table for Arabic data reference.

View 3 Replies View Related

SQL & PL/SQL :: Converting BLOB Data To Long Or Varchar

Feb 6, 2013

converting BLOB data into varchar2 or long .

we have function which convert long data and return it has varchar . But has part of Apps upgrade the Column has been converted into blob column.

How we need the same function to read the data from BLOB and return its as long or varchar2.

Somewhere i am making mistake..

CREATE OR REPLACE function GDS.test_alert_msg(v_rowid rowid) return varchar2 is

vblob blob;
i2 number;
amt number :=32767;
len number;
pos raw(32767);
position INTEGER := 10000;
my_vr raw(32767);

[Code]....

View 2 Replies View Related

SQL & PL/SQL :: Create Select Query That Will Get Data From 18 Months Ago Based On Sysdate?

Sep 9, 2013

I have a table with columns job_id, jan, feb, mar ... , and year

I need to create a select query that will get the data from 18 months ago based on sysdate.

So something like:

Select to_char(add_months(sysdate, -18),'MON') from table1 where job_id = 56947 and year = to_char(add_months(sysdate, -18),'YYYY');

However I need the result of to_char(add_months(sysdate, -18),'MON') to actually act as a column name, not a string result.

View 23 Replies View Related

PL/SQL :: Sync Data From Emp To Emp_target Table Daily (sysdate - 1) Records

May 8, 2013

Think that emp as an oltp table i want to sync the data from emp to emp_target table daily(sysdate - 1) records

SQL> create table emp_target as select * from emp where 1=2;

Table created.

View 9 Replies View Related

Application Express :: Select Some Data From Table Base On SYSDATE?

Sep 6, 2012

I'm trying to select some data from table base on SYSDATE. The below query does not return any data.

My query is:

select count(TICKET_ID) "ECEMEA" from QTMT_TICKETS where STATUS_ID=1 and TEAM_ID=3 and RECEIVED_DATE=sysdate

why this does not work? Date format in my application is: DD-MMM-YY (16-AUG-12). In the database the dates are stored in this format: MM/DD/YYYY (08/25/2012). Does it mean, that I have to play with the format?

View 6 Replies View Related

SQL & PL/SQL :: Compare Two Table Data

Mar 5, 2010

How to identify the columns which are different between two oracle tables. I have nearly 30 columns in each table comprising of million rows

View 11 Replies View Related

SQL & PL/SQL :: Compare Values In A Column Data

Aug 29, 2012

I have an requirement like below and would like to have SQL for that.

Source Table:

EMP_NO EMP_CODE
1 'A'
1 'D'
1 'E'
1 'F'

2 'S'
2 'A'
2 'W'
2 'Q'

3 'A'
3 'T'
3 'D'
3 'E'

4 'D'
4 'A'

I want to load only data which has EMP_CODE as A and doesn't have subsequent 'E' or 'F' in it. In the above source you can see EMP_NO 2 and 4 satisfy the condition and rest wont. So i want the output data like below.

Desired output:

EMP_NO EMP_CODE
2 'A'
4 'A'

View 4 Replies View Related

SQL & PL/SQL :: How To Compare Data In Nested Table

Mar 12, 2012

create type nesttype as table of clob;

create table emp
(empno number,
ename varchar2(1000),
language_known nesttype
)

I want to check whether language is already there in database or not.

i have written the below query

select * from emp where language_known =nesttype('english','hindi');

i am getting the below error

SQL Error: ORA-22901: cannot compare nested table or VARRAY or LOB attributes of an object type
22901. 00000 - "cannot compare nested table or VARRAY or LOB attributes of an object type"
*Cause: Comparison of nested table or VARRAY or LOB attributes of an
object type was attempted in the absence of a MAP or ORDER
method.
*Action: define a MAP or ORDER method for the object type.

How to compare data in nested table

View 16 Replies View Related

Compare Non Numeric Data Using Arithmetic Operations?

Feb 22, 2013

Is there anyway to compare the non numeric data in a table to a numeric number.Want to run a query like

SELECT rank_id
FROM   mas_rank
WHERE  rank_code > 26 Rank_code contains numeric as well as some non numeric data

View 8 Replies View Related

Networking And Gateways :: Compare Table Data From Two Different Databases

Jun 1, 2010

1) how to to compare sybase table data with oracle database table data?

2) how to connect sybase database from oracle database?

View 5 Replies View Related

SQL & PL/SQL :: Custom Date Or Data Type To Compare Semesters

Jul 26, 2011

I have a table with two columns called startsem and gradsem they are both CHAR(3). Within those colums are rows that are listed as SemesterYear. For example, F09 is Fall 2009, S09 Spring 2009, and M09 is Summer 2009. I would like to create a constraint that says GradSem must be greater than StartSem b/c no one can travel back in time to graduate. However, as you know you can compare S09 > F09 because it will treat it as a string. I thought I could use a substring and compare the last two digits as a year and that would work but how do I compare the semesters as a time frame? Because in my schema F > S because Spring 2011 comes before Fall 2011 but in reality F < S because to Oracle it is a string and the ASCII value of F is less than S. I cannot chage the coding of the database so editing the rows so they are more date friendly is not an option.

So how can I modify this database to acruately compare StartSem and GradSem.

View 7 Replies View Related

How To Compare Data Of Clob And Long Datatypes Using DBLink

Aug 13, 2012

I would like to run below query on all tables, however it doesnt work on clob and long datatypes

select * from owner.table_name
minus
select * from owner.table_name@remote_db;
from dba_tables
where owner in ( '....');

ORA-00932: inconsistent datatypes: expected - got CLOB

How can I compare the data of clob and long datatypes using dblink ?

View 2 Replies View Related

SQL & PL/SQL :: Data Between 2 Dates

Dec 21, 2011

below is the table and data

create table bday (name varchar2(30),bdate varchar2(10));

insert into bday values('jeffery','0110');
insert into bday values('boss','1231');
insert into bday values('raj','1225');

[Code]...

the BDATE column is in the form "mmdd".

I just want to select the name between 2 dates ( not including years). lets say between sysdate and sysdate+20, i.e

select to_char(sysdate,'dd-mon'),to_char(sysdate+25,'dd-mon') from dual;

TO_CHAR(SYSDATE,'DD-MON') TO_CHAR(SYSDATE+25,'DD-MON')
21-dec 15-jan

but when I run the below query, it is not showing me 'january' data

select name from bday
where to_date(bdate,'mm/dd') between sysdate and sysdate+25;

o/p comes as:
NAME BDATE
boss 1231
raj 1225

but the actual o/p should be:

NAME BDATE
boss 1231
raj 1225
jeffery 0110

it seems to me that because of year change the rows are not displayed.how to handle this in single SQL

View 8 Replies View Related

Select Data Between Two Dates?

Sep 21, 2004

I am wondering how can I select data between two dates (ie from 08/12/2004 to today?)

Name DateS
Bob 08/11/2004
Tom 08/12/2004
Bill 09/21/2004 <-- today

return

Tom 08/12/2004
Bill 09/21/2004

View 4 Replies View Related

SQL & PL/SQL :: How To Print Data Between Two Dates

Oct 8, 2012

How to print data between two dates... startdate and enddate inclusive

View 2 Replies View Related

SQL & PL/SQL :: Retrieving Data Between Two Dates

Nov 3, 2011

I have one table when I am querying like below

select * from timeoffreqitem
where timeoffreqitemid=134

getting data like below

134 144 07-OCT-11 13-OCT-11 134

I need to see this result as below.

134 144 07-OCT-11 13-OCT-11 134
134 144 08-OCT-11 13-OCT-11 134
134 144 09-OCT-11 13-OCT-11 134
134 144 10-OCT-11 13-OCT-11 134
134 144 11-OCT-11 13-OCT-11 134
134 144 12-OCT-11 13-OCT-11 134
134 144 13-OCT-11 13-OCT-11 134

I am looking at multilple optons.

View 1 Replies View Related

PL/SQL :: Select Dates With No Data?

Oct 8, 2012

I have an PL/SQL query which gives the data between the date interval submitted by the user.The problem is that i want all the date irrespective of it has data or not for eg: Let say date parameter is from 1-Jan-2012 to 5-Jan-2012

Now, in the database the available dates are:

1-Jan-2012
2-Jan-2012
5-Jan-2012

So as you can see here that dates 3-Jan-2012 and 4-Jan-2012 is not resulted out by the query. I want all the dates.

So the output should be like this:

1-Jan-2012
2-Jan-2012
3-Jan-2012
4-Jan-2012
5-Jan-2012

View 5 Replies View Related

How To Take Data When Entering Range Of Dates

Oct 8, 2009

how can i write query to take data from DB, if im entering range of dates :

for example between 20-aug-2009 and 1-aug-2009.

But query must be like, if i enter 21-aug-2009 and second date should the start of the month.

for example if i enter second date like 2-jul-2009, first date should start form begining of that month?

View 1 Replies View Related

Select Data Between Subquery Dates?

Sep 5, 2012

I have an athletics participation table that only has the relevant emplid and effective date field. There is no term field on the table. I'm trying to only select those emplid's where the max( effdt) for the emplid is between the begin and end date of the current term. I only want to select current athletes. I would much rather it be for the current academic year but it seems impossible. Why can't I use max(effdt) here?

sql Code

AND h.emplid IN(SELECT b.emplid FROM PS_ATHL_PART_STAT b
where max(b.effdt) between (SELECT term_begin_date AND term_end_date
from PS_TERM_TBL

[Code].....

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved