How to compare two dates
Hi,
I have two colums(start date &end date) of data type date in my page and both are optional ones.
I need to have a validation on those date columns,
End date should not be greater than Start Date.
This validation should be triggered once i click on Apply button.
Pseudo Code:
If (endate>startdate)
raise form_trigger_failure;
Can anyone suggest how/where to implement the code, if possible please provide the sample code.
Thanks,
Mahesh
sorry, I was thinking java and not oaf
there is similar thing thats done in tutorials exercise create page part2
this is the code snippet from jdev guide...but you may want to go through the chapter before you put this code in your EO file.
Step 10.2 Add a validateEndDate() method Add the following new method to your EmployeeEOImpl class. /*
* Verifies that the employee's End Date is valid.
* Business Rules:
* This is an optional value which can be updated at any time.
* Cannot be earlier than sysdate.
protected void validateEndDate(Date value)
// If a value has been set, validate it.
if (value != null)
OADBTransaction transaction = getOADBTransaction();
// Note that we want to truncate these values to allow for the possibility
// that we're trying to set them to be the same day. Calling // dateValue( ) does not include time. Were we to want the time element,
// we would call timestampValue(). Finally, you cannot compare
// oracle.jbo.domain.Date objects directly. Instead, convert the value to
// a long as shown.
long sysdate = transaction.getCurrentDBDate().dateValue().getTime();
long endDate = value.dateValue().getTime();
if (endDate < sysdate)
throw new OAAttrValException(OAException.TYP_ENTITY_OBJECT,
getEntityDef().getFullName(), // EO name
getPrimaryKey(), // EO PK
"EndDate", // Attribute Name
value, // Attribute value
"AK", // Message product short name
"FWK_TBX_T_END_DATE_PAST"); // Message name
} // end validateEndDate()
Similar Messages
-
How to Compare two Dates in java
How to Compare two Date Field after getting the values from jTextField1.getText() and jTextField2.getText().
Date d1=DateFormat.getDateInstance().parse(yourstring1);
same for d2
d1.compareTo(d2);
could be that i misrememberd the exact naems of some functions or mixed up something in the equence of d1= -
How to compare two dates that should not exceed morethan 3 years
hi all,
can you please tell me how to compare two dates( basically dates are string type)
that should not exceed more than 3 years? in JAVASCRIPT
Thanks in Advance.This is not a JavaScript forum.
[*Google* JavaScript Forum|http://www.google.co.uk/search?q=JavaScript+Forum&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-GB:official&client=firefox-a]
Good luck. -
How to compare two dates to know which one is greater than oher?
how to compare two dates to know which one is greater than oher?
Please search before asking basic questions.
Edited by: Rob Burbank on Mar 27, 2009 9:26 AMHi,
If thse to date fields are of same type u can directly compare like this.
regards,
Bharat. -
How to compare two date Objects
Hi,
I have two Calendar Objects, one is coming from client and one is my server time, I need to evaluate that incoming time with server time so that if it is sent before an hour back then i should not do anything on that request Object. I have converted the incoming String into Calendar Object and how can i evaluate these two Calendar Objects including their hours and minutes.
Thanks in advance
bajjubajjurireddy, ignore Mobiquity's post. It contains no useful information and will only serve to confuse and frustrate you.
Mobiquity wrote:
Also make sure that the two date objects are in the same date format..
public static String DateToDateString(java.util.Date d, String dateFormat)
throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
sdf.setLenient(false); // this is required else it will convert
String dateString = sdf.format(d);
return dateString; -
How to compare two rows from two table with different data
how to compare two rows from two table with different data
e.g.
Table 1
ID DESC
1 aaa
2 bbb
3 ccc
Table 2
ID DESC
1 aaa
2 xxx
3 ccc
Result
2Create
table tab1(ID
int ,DE char(10))
Create
table tab2(ID
int ,DE char(10))
Insert
into tab1 Values
(1,'aaa')
Insert
into tab1 Values
(2,'bbb')
Insert
into tab1 Values(3,'ccc')
Insert
into tab1 Values(4,'dfe')
Insert
into tab2 Values
(1,'aaa')
Insert
into tab2 Values
(2,'xx')
Insert
into tab2 Values(3,'ccc')
Insert
into tab2 Values(6,'wdr')
SELECT
tab1.ID,tab2.ID
As T2 from tab1
FULL
join tab2 on tab1.ID
= tab2.ID
WHERE
BINARY_CHECKSUM(tab1.ID,tab1.DE)
<> BINARY_CHECKSUM(tab2.ID,tab2.DE)
OR tab1.ID
IS NULL
OR
tab2.ID IS
NULL
ID column considered as a primary Key
Apart from different record,Above query populate missing record in both tables.
Result Set
ID ID
2 2
4 NULL
NULL 6
ganeshk -
How to compare two rows in PL/SQL?
Hi All,
How to compare two rows in PL/SQL? Is there any method that I can use instead of comparing them column by column?
Any feedback would be highly appreciated.PhoenixBai wrote:
Hi All,
How to compare two rows in PL/SQL? Is there any method that I can use instead of comparing them column by column?What "rows" are you referring to?
If you're talking of rows within a PL/SQL associative array there are techniques as described in the documentation... e.g.
SQL> ed
Wrote file afiedt.buf
1 declare
2 type v1 is table of number;
3 r1 v1 := v1(1,2,4);
4 r2 v1 := v1(1,2,3);
5 begin
6 if r1 MULTISET EXCEPT DISTINCT r2 = v1() then
7 dbms_output.put_line('Same');
8 else
9 dbms_output.put_line('Different');
10 end if;
11* end;
SQL> /
Different
PL/SQL procedure successfully completed.
SQL> ed
Wrote file afiedt.buf
1 declare
2 type v1 is table of number;
3 r1 v1 := v1(1,2,3);
4 r2 v1 := v1(1,2,3);
5 begin
6 if r1 MULTISET EXCEPT DISTINCT r2 = v1() then
7 dbms_output.put_line('Same');
8 else
9 dbms_output.put_line('Different');
10 end if;
11* end;
SQL> /
Same
PL/SQL procedure successfully completed.
SQL>If you're talking about rows on a table then you can use the MINUS set operator to find the rows that differ between two sets of data...
SQL> select * from emp;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 SMITH CLERK 7902 17-DEC-1980 00:00:00 800 20
7499 ALLEN SALESMAN 7698 20-FEB-1981 00:00:00 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-1981 00:00:00 1250 500 30
7566 JONES MANAGER 7839 02-APR-1981 00:00:00 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-1981 00:00:00 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-1981 00:00:00 2850 30
7782 CLARK MANAGER 7839 09-JUN-1981 00:00:00 2450 10
7788 SCOTT ANALYST 7566 19-APR-1987 00:00:00 3000 20
7839 KING PRESIDENT 17-NOV-1981 00:00:00 5000 10
7844 TURNER SALESMAN 7698 08-SEP-1981 00:00:00 1500 0 30
7876 ADAMS CLERK 7788 23-MAY-1987 00:00:00 1100 20
7900 JAMES CLERK 7698 03-DEC-1981 00:00:00 950 30
7902 FORD ANALYST 7566 03-DEC-1981 00:00:00 3000 20
7934 MILLER CLERK 7782 23-JAN-1982 00:00:00 1300 10
14 rows selected.
SQL> select * from emp2;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7521 WARD SALESMAN 7698 22-FEB-1981 00:00:00 1250 500 30
7566 JONES MANAGER 7839 02-APR-1981 00:00:00 2975 20
7782 CLARK MANAGER 7839 09-JUN-1981 00:00:00 2450 10
7788 SCOTT ANALYST 7566 19-APR-1987 00:00:00 3000 20
7839 KING PRESIDENT 17-NOV-1981 00:00:00 5000 10
7900 JAMES CLERK 7698 03-DEC-1981 00:00:00 950 30
7934 MILLER CLERK 7782 23-JAN-1982 00:00:00 1300 10
7 rows selected.
SQL> select * from emp
2 minus
3 select * from emp2;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 SMITH CLERK 7902 17-DEC-1980 00:00:00 800 20
7499 ALLEN SALESMAN 7698 20-FEB-1981 00:00:00 1600 300 30
7654 MARTIN SALESMAN 7698 28-SEP-1981 00:00:00 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-1981 00:00:00 2850 30
7844 TURNER SALESMAN 7698 08-SEP-1981 00:00:00 1500 0 30
7876 ADAMS CLERK 7788 23-MAY-1987 00:00:00 1100 20
7902 FORD ANALYST 7566 03-DEC-1981 00:00:00 3000 20
7 rows selected.If you actually need to know what columns data is different on "non-matching" rows (based on your primary key) then you'll have to compare column by column. -
How to compare two Universes ?
Post Author: Shrikant
CA Forum: Administration
Hi.. all I want to compare two universes of different data mart to check the table structure. Can anybody please tell me how to compare two Universes of different Datamarts?How i can achive this usinig BusinessObjects Enterprise XI Release 2 ??
Thanks in advance.
ShrikantCreate
table tab1(ID
int ,DE char(10))
Create
table tab2(ID
int ,DE char(10))
Insert
into tab1 Values
(1,'aaa')
Insert
into tab1 Values
(2,'bbb')
Insert
into tab1 Values(3,'ccc')
Insert
into tab1 Values(4,'dfe')
Insert
into tab2 Values
(1,'aaa')
Insert
into tab2 Values
(2,'xx')
Insert
into tab2 Values(3,'ccc')
Insert
into tab2 Values(6,'wdr')
SELECT
tab1.ID,tab2.ID
As T2 from tab1
FULL
join tab2 on tab1.ID
= tab2.ID
WHERE
BINARY_CHECKSUM(tab1.ID,tab1.DE)
<> BINARY_CHECKSUM(tab2.ID,tab2.DE)
OR tab1.ID
IS NULL
OR
tab2.ID IS
NULL
ID column considered as a primary Key
Apart from different record,Above query populate missing record in both tables.
Result Set
ID ID
2 2
4 NULL
NULL 6
ganeshk -
How to compare two Universes of two different Datamarts?
Post Author: Shrikant
CA Forum: Integrated Solutions
Hi.. all I want to compare two universes of different data mart to check the table structure. Can anybody please tell me how to compare two Universes of different Datamarts?How i can achive this usinig BusinessObjects Enterprise XI Release 2 ??
Thanks in advance./*does record 1 have friend*/
WITH t AS
(SELECT 1 AS Id, 'a' AS NAME, 'type1' AS Col
FROM Dual
UNION ALL
SELECT 2 AS Id, 'a' AS NAME, 'type1' AS Col
FROM Dual
UNION ALL
SELECT 3 AS Id, 'a' AS NAME, 'type2' AS Col FROM Dual)
SELECT count(*) as YesNo
FROM t T1
WHERE T1.Id = 1
AND (T1.Name, T1.Col) IN (SELECT T2.Name, T2.Col FROM T t2 where t2.ID != T1.Id);
1
/*does record 3 have friend*/
WITH t AS
(SELECT 1 AS Id, 'a' AS NAME, 'type1' AS Col
FROM Dual
UNION ALL
SELECT 2 AS Id, 'a' AS NAME, 'type1' AS Col
FROM Dual
UNION ALL
SELECT 3 AS Id, 'a' AS NAME, 'type2' AS Col FROM Dual)
SELECT count(*) as YesNo
FROM t T1
WHERE T1.Id = 3
AND (T1.Name, T1.Col) IN (SELECT T2.Name, T2.Col FROM T t2 where t2.ID != T1.Id);
0
*/ -
How to compare table data and table field
Hi buddy,
I have some question about how to compare table data and table field.
1. I know there is one method: CL_ABAP_UNIT_ASSERT=>ASSERT_TABLE_CONTAINS , it use in unit test to compare the table data(A and B) , you can loop table A into structure A1, then use this mehtod it can compare whether table B contain structure A1. but when I try to use this in main program it will dump.
CL_ABAP_UNIT_ASSERT=>ASSERT_TABLE_CONTAINS(
LINE = A1
TABLE = B ).
Is there any method or FM can be used to compare the table data ?
2. I also want to compare two table field , try to find out the different. How to realize this.
Thank you for your sincerely answer.Hi Zongjie,
What`s the difference, if you using loop A into wa_A, read table B into wa_B with all field, then compare with wa_A and wa_B.
The question 2, seems no standard FM available here.
Loop A into wa_A.
Loop B into wa_B.
if wa_A-field1 eq wa_B-field1.
endif.
if wa_A-field2 eq wa_B-field2.
endif.
endloop.
endloop.
regards,
Archer -
Comparing two dates and adding days to date
Hi,
I want to compare two dates(like 2006/10/21 and 2006/11/2),how can i compare these two dates,like which is greater.And if to the second date,i want to add some number of days like 10 days,how can i add so that the date becomes 2006/11/12).
Please reply soon.ThanksNo,all other queries are different,as they have the
date in this format
'2006-03-06 " but i have the date in this format
"2006-03-06 10:26:46.0",
i.e the time is also assciated with it.
If I have only the date(in string format or date
date format 2000/12/1),then I can easily do it,but
I have the time also.If I have the date only,then I
can split the date into three strings,and after
converting into integer I can pass it to the
constructor,but what about the time?SimpleDateFormat can parse "2006-03-06 10:26:46.0" date too:
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SS");
Date date = dateFormat.parse("2006-03-06 10:26:46.0");
System.out.println("date = " +date); -
Java 1.3 comparing two dates using Calendar.before(Calendar)
Has anyone used the Calendar.before() method for comparing two dates, how accurate is this?
Some users have found problem with this method, is this true?manjit84 wrote:
Has anyone used the Calendar.before() method for comparing two dates, Yes.
how accurate is this?I've never noticed a problem.
Some users have found problem with this method, is this true?Check the bug database^1^?
^1^ http://bugs.sun.com/ -
??how to compare two resultsets??
hi all!
i need to find out whether two resultsets contain the same data.
the only way i know how to do it in java is to put them into a while loop and fetch the contents first and then compare the contents.
but is there an easier way to compare resultsets?
does anyone know how to compare two resultsets without extracting the data?
the code example here executes two identical queries on an oracle database, compare and print the resultsets.
public ResultSet getResultset(String query)
ResultSet rs=null;
try { rs=Stmt.executeQuery(query); }
catch(Exception e) { e.printStackTrace(); }
return rs;
public static void main(String[] args) {
ResultSet r1=null;
ResultSet r2=null;
try {
database db = new ddatabase();
r1=db.getResultset("Select 'name' from person");
r2=db.getResultset("Select 'name' from person");
if (r1 == r2) {
System.out.println("ok");
System.out.print(r1);
System.out.println();
System.out.print(r2);
else {
System.out.println("not ok");
System.out.print(r1);
System.out.println();
System.out.print(r2);
jdbc.cleanup();
catch(Exception e) {e.printStackTrace();}
and here is the output:
F:\java rs_compare
not ok
oracle.jdbc.driver.OracleResultSetImpl@4413ee
oracle.jdbc.driver.OracleResultSetImpl@786e64
as you can see the resultsets are different though the data they contain have to be the same.
so the 'if(resultset#1 == resultset#2)' does not work.
thanks for any help
best regards
5ithl0rdDon't cross-post.
I'll bet ResultSet implementations don't override equals() to provide "deep equals" behavior, in which case it'll be no different than using "==".
It's a bad idea to compare two ResultSets this way. You'll have to load both into objects or data structures and compare those in a "deep" way.
Besides, the ONLY way two ResultSets could be different, given the same query, would be if there were multiple clients that could write to the table between queries and change the underlying data. If your two queries are sufficiently isolated, I'd say that the same query will return the same ResultSet.
% -
Hi all,
How to compare two IDoc's. If the both the IDocs are are of same type, i want to distinguish the data in those two IDocs.
Thank you in Advance
Regards
HarshaHi Harsha,
Transaction WE05 will help you out.You should first know some details like the
iDoc type, partner, the date/time and maybe the iDoc #. There can be many iDocs
generated/processed per day and without having some info to start with,
one will never find anything useful. Filter what you can, and then
navigate in the left hand frame/double click on the results lines in the
right hand frame to drill down. Eventually you will see the single iDoc
with all the many 'segments' available. Expand the 'data records'
branch (and sub-branches) to see each 'segment' and find the data fields
& values (these will appear in the lower right hand frame).
Reward points if helpful..
Regards,
Goutham. -
Compare two dates with NULL in one
I am trying to do the following with a simple SQL. Compare two dates and get the latest one, but the greatest() function always returns NULL if NULL is present. So how can I do it ?
Date1 Date2 Desired Result
Null 01-Dec-09 01-Dec-09
01-May-09 01-Mar-09 01-May-09
01-May-09 NULL 01-May-09
01-May-09 01-Nov-09 01-Nov-09
NULL NULL NULL
Any suggestion ? ThanksHi,
Try this,
create table test1
fdate date,
tdate date
insert into test1 values (null,'25-jan-2010');
select greatest(nvl(fdate,tdate),nvl(tdate,fdate)) greatest from test1;
Thanks&Regards,
Jai
Maybe you are looking for
-
More on "maximum open cursors exceeded"
It seems a lot of people have been seeing this error message, but reading through the posts on the topic hasn't given me any new insight on the problem. Here's an account of my particular situation: I am using the XSQL servlet, v.1.0.0.0 with the thi
-
Classic Brochure Page Numbering
My first brochure! Using Classic template. I have the cover finished and saved but SOMEHOW the "inside" got saved on "page 3". In other words, now when I look at my page thumbnails, I see: Page 1 (with my cover) Page 2 (blank, other than template col
-
HELP!! I KEEP GETTING THE WHITE SCREEN OF DEATH!!
Here's how it started: My Cruve 8520 died and told me to reinstall the software. I installed the latest software update, and now my phone just goes white. Usually when my battery is low, but at random times as well. The only thing the helps is hooki
-
Where oh where have my projects gone?
I am new to FCPX. Started with a few projects to test it out, imported footage from external hard drives... Started working. The next thing I knew I was putting together a video for work and after ejecting my hard drive and taking it with me... FCP
-
Document flow for notification
Dear all, i have created notification from a reference notification, however i need to see that document flow. From notification menu, when i enter document flow it does not show reference notification? any customizing for that? Thanks