How to compare 2 timestamp value (in terms of minutes)
Hi all.
I've got 2 timestamp value a,b. I would like to count the different (in terms of minutes).
I tried a.compareTo(b), but it's not work.
pls help.
Thanks
Regards,
Kin
I assume by "timestamp value" you mean Dates or longs.
Ever thought of basic maths?
date a - date b? Dates can be expressed in longs, as you might know.
For more info read the API.
Similar Messages
-
How to compare the value of a specied attribute to a string
I am looking for an example of how to compare the value of an attribute to a string. (I think)
I have been trying to:
if (attrs.get("title")== "Vampire") -- you already know this did not work.
How can I check to see if the title="Vampire"?
The code below will get me the title of admin (which should be Vampire)
import javax.naming.Context;
import javax.naming.directory.InitialDirContext;
import javax.naming.directory.DirContext;
import javax.naming.directory.Attributes;
import javax.naming.NamingException;
import java.util.Hashtable;
class Giles {
public static void main(String[] args) {
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldap://192.168.1.55:389/o=sunnydale");
try {
DirContext ctx = new InitialDirContext(env);
Attributes attrs = ctx.getAttributes("cn=admin");
System.out.println("Title: " + attrs.get("title").get());
ctx.close();
} catch (NamingException e) {
System.err.println("Problem getting attribute: " + e);
Thank you!!
SteveI guess, you are looking for searching for attributes of an user object.
Here is the sample code to list all the attributes of an 'user' objectclass.
Tell me if it helps or not.
import java.util.Hashtable;
import javax.naming.ldap.*;
import javax.naming.directory.*;
import javax.naming.*;
public class GetAttributes
public static void main (String[] args)
Hashtable env = new Hashtable();
//Must use either the userPrincipalName or samAccountName,
//Cannot use the distinguished name
String adminName = "cn=abcd,cn=Users,dc=ssotest,dc=com";
String adminPassword = "DEF1234";
String ldapURL = "ldap://pni3w067:389";
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.SECURITY_AUTHENTICATION,"simple");
env.put(Context.SECURITY_PRINCIPAL,adminName);
env.put(Context.SECURITY_CREDENTIALS,adminPassword);
//connect to my domain controller
env.put(Context.PROVIDER_URL,ldapURL);
try {
// Create the initial directory context
DirContext ctx = new InitialLdapContext(env,null);
// Create the search controls
SearchControls searchCtls = new SearchControls();
//Specify the search scope
searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE);
//specify the LDAP search filter
String searchFilter = "(&(objectClass=user))";
//Specify the Base for the search
//cn=policygroup,ou=policyusers,ou=ssoanay,;
//String searchBase = "ou=policyusers,ou=ssoanay,dc=ssotest,dc=com";
String searchBase = "cn=abcd,cn=users,dc=ssotest,dc=com";
//initialize counter to total the results
int totalResults = 0;
// Search for objects using the filter
NamingEnumeration answer = ctx.search(searchBase, searchFilter, searchCtls);
//Loop through the search results
while (answer.hasMoreElements()) {
SearchResult sr = (SearchResult)answer.next();
totalResults++;
System.out.println("\nName of Object : " + sr.getName());
// Print out some of the attributes, catch the exception if the attributes have no values
Attributes attrs = sr.getAttributes();
//System.out.println("6");
if (attrs != null) {
try {
/*NamingEnumeration enum = attrs.getIDs();
while(enum.hasMore()) {
System.out.println("IDs:"+enum.next().toString());
NamingEnumeration enum2 = attrs.getAll();
while(enum2.hasMore()) {
System.out.println("Attribute - "+enum2.next().toString());
catch (Exception e) {
System.out.println("Exception:" +e.getMessage());
else {
System.out.println("attribute is null");
System.out.println("Total results: " + totalResults);
ctx.close();
catch (NamingException e) {
System.err.println("Problem searching directory: " + e);
//return 0;
} -
How to compare the values stored in the list
Hi,
I am having the requirement that i want to compare the values stored in the list.How to store the values in the list and compare the list values stored inside it.
Regards,
Ahamadhttp://java.sun.com/j2se/1.5.0/docs/api/java/util/Collections.html#sort(java.util.List)
http://java.sun.com/j2se/1.5.0/docs/api/java/util/Collections.html#sort(java.util.List,%20java.util.Comparator)
http://java.sun.com/j2se/1.5.0/docs/api/java/util/Comparator.html
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Comparable.html -
How to compare, current value in :block.text_item with the database value
Hi
Could you please tell me
How to compare the current value in :block.text_item with the corresponding database column value.
I am using forms 10g
There is block and there is an text Item in that block.
When I run the form and query the block (tabular), the :block.text_item shows me, whatever value there in the database.
Now I add some value in the :block.text_item to the existing value.
now
the :block.text_item contains old+ new added value
whereas
the database table contains 'old' value
Now on a button click , I want to find out what is the value that I have added
Could you please tell me, is it possible without writing a select query?Hello,
Now on a button click , I want to find out what is the value that I have addedSo you mean always user will add value in the existing value. Because this way will fail in one case. Let say
Value in Database is = ABCD
User opened the form and he removed the D and write E and now value is ABCE and length is still same 4. So, there is no addition.
Anyway you can know the database value at runtime there is one property for item called DATABASE_VALUE. It gives the value which is in database while you are running the form before save. and you can use like this..
Trigger = WHEN-MOUSE-DOUBLE-CLICK on item level
DECLARE
vItemValue DATATYPE; -- Set the data type according to your desired field.
vValueAdded DATATYPE; -- Set the data type according to your desired field.
BEGIN
vItemValue:=GET_ITEM_PROPERTY('ITEM_NAME',DATABASE_VALUE); -- It will return you the database value in vItemValue variable.
IF LENGTH(vItemValue)>LENGTH(:FORM_ITEM_NAME) THEN -- It mean something change or added
vValueAdded:=SUBSTR(:FORM_ITEM_NAME,LENGTH(vItemValue)+1);
MESSAGE('Added value is : '||vValueAdded); -- It will show you the added value.
END IF;
-- now suppose you want to show the old and new value in message not the added one
-- Then no need of IF condition. You can just use message like this
-- And i would prefer to use like this way
MESSAGE('Old Value : '||vItemValue||' New Value - '||:FORM_ITEM_NAME);
MESSAGE('Old Value : '||vItemValue||' New Value - '||:FORM_ITEM_NAME);
END;Hope it is clear.
-Ammad -
Friends
Could some one help me with Time values...
I would like to compare two time values one of which is stored as a string. so i would like to how to compare the system time with another column which has a string stored in time format..
i mean Sysdate - 10:30:00
Thanks in advance..select 'Y' from dual
where to_char(sysdate, 'HH24:MI:SS') = '10:30:00'
SQL> ed
Wrote file afiedt.buf
1 select 'Y' from dual
2* where to_char(to_date('10-02-2006 10:30:00', 'DD-MM-YYYY HH24:MI:SS'), 'HH24:MI:SS') = '10:30:0
SQL> /
Y
SQL> Cheers
Sarma.
Message was edited by:
Radhakrishna Sarma -
How to compare single value with multiple values
In my query I have something like this:
A.SOR_CD=B.SOR_CODE where A and B are 2 different tables. This condition is in the where clause. The column in table A has single values but some values in table B have multiple comma separated values (822, 869, 811, ..). I want to match this single
value on the left side with each of the comma separated values. Please let me know how will I be able to do it. The number of comma separated values on the right side may vary.Hi MadRad123,
According to your description, you want to compare single value with multiple values in your query. Right?
In this scenario, the table B has comma separated values, however those comma separated values are concatenated into a string. So we can use charindex() function to return the index of the table A value. And use this index as condition in
your where clause. See the sample below:
CREATE TABLE #temp1(
ID nvarchar(50),
Name nvarchar(50))
INSERT INTO #temp1 VALUES
('1','A'),
('2','A'),
('3','A'),
('4','A'),
('5','A')
CREATE TABLE #temp2(
ID nvarchar(50),
Name nvarchar(50))
INSERT INTO #temp2 VALUES
('1','a,A'),
('2','A,B'),
('3','c'),
('4','A,C'),
('5','d')
select * from #temp1 a inner join #temp2 b on a.ID=b.ID
where CHARINDEX(a.Name,b.Name)>0
The result looks like below:
Reference:
CHARINDEX (Transact-SQL)
If you have any question, please feel free to ask.
Best Regards,
Simon Hou -
How to compare previouse value in pl/sql array
DECLARE
CURSOR stg_raw_cur IS
SELECT RAW_STG_ID,
DEVICE_CD,
MODEL_VERSION,
PLATFORM_CD,
PROFILE_COOKIE,
LOCATION_CD,
SAMPLE_RATE,
EVENT_TYPE_CD,
to_char(to_date(to_date(substr(EVENT_DATE_TIME,1,8),'yyyymmdd')-1 ||
'T' ||
substr(EVENT_DATE_TIME,10,8)
|| 'Z','DD-MON-RR"T"HH24:MI:SS"Z"'), 'YYYYMMDDYY"T"HH24:MI:SS"Z"' ) EVENT_DATE_TIME,
EVENT_SPECIFIC,
BATCH_ID,
DWH_ARVL_DT,
DWH_ARVL_DT_ID,
DWH_CREATE_DT from dwh_stg.stg_raw where batch_id >= 200
order by batch_id asc;
TYPE stgrawarr IS TABLE OF stg_raw_cur%ROWTYPE;
stg_raw_rec stgrawarr;
l_batch_id NUMBER :=0 ;
v_ctr NUMBER :=0;
l_temp_batch_id number :=0;
BEGIN
OPEN stg_raw_cur;
LOOP
FETCH stg_raw_cur BULK COLLECT INTO stg_raw_rec LIMIT 100;
EXIT
WHEN stg_raw_cur%NOTFOUND;
END LOOP;
CLOSE stg_raw_cur;
for i in stg_raw_rec.first..stg_raw_rec.last
loop
dbms_output.put_line('batch id is '|| stg_raw_rec(i).batch_id );
IF l_batch_id != stg_raw_rec(i).batch_id
then
dbms_output.put_line('Different');
end if;
l_temp_batch_id := stg_raw_rec(i).batch_id;
commit;
end loop;
END;
I want to compare previous value of stg_raw_rec(i).batch_id if differnet then increament the value
else leave the same.
thanks.Try this,
FOR i IN stg_raw_rec.FIRST .. stg_raw_rec.LAST
LOOP
IF l_temp_batch_id != stg_raw_rec (i).batch_id
THEN
--increment
l_temp_batch_id := l_temp_batch_id + 1;
END IF;
DBMS_OUTPUT.PUT_LINE ('batch id is ' || stg_raw_rec (i).batch_id||' unique batch id is '||l_temp_batch_id);
-- DBMS_OUTPUT.PUT_LINE ('batch id is ' || stg_raw_rec (i).batch_id);
-- IF l_batch_id != stg_raw_rec (i).batch_id
-- THEN
-- DBMS_OUTPUT.PUT_LINE ('Different');
-- END IF;
l_temp_batch_id := stg_raw_rec (i).batch_id;
COMMIT;
END LOOP; -
How to compare the value of a cell before changing and after changing.
Hey there,
Now I want to implement a JTable. And the requirement is that users can edit a cell in the Table only once. I think there are two possible ways. One is that after user edited a cell, I will set this cell read only. Another way is to compare the vaule before and after the changing. If it is different, then write back the previous value.
But I did not know how to implement in Java. Can anybody help me?
Thanks alot!
Shellyinevitably, you will have to save a before copy of
the data, what this many times amounts to is that you
will need to have 2 identical data structures before
you start or some type of locking mechanism for each
piece of data.Why is this inevitable? I don't see it as inevitable at all. In fact, it's quite simple to implement a TableModel that returns false when isEditable(int, int) is invoked for any cell that has already had setValueAt(Object, int, int) inovked on it, for example. Depending on the requirements and implementation a different methodology may be needed for determining when the edit has taken place, such as a custom editor that notifies the TableModel when stopCellEditing() is invoked. Heck, overriding editingStopped() in JTable to do it might even work.
So, create a TableModel that returns isEditabe(int, int) as true only if the cell hasn't been edited yet. The only problem to solve from there is how you know when it's been edited. I've already given you a few leads on that, it's not particularly hard but depending on your exact implementation it may require different solutions. -
How to compare 3 values in array
Hi all
This is my first post so please be tolerant
I need to find "bad values" in array, it will be easier to explain it using example so:
I have array like this: 0 0 0 0 0 0 0 0 5 0 0 0 0 <- so "5" is the bad value, my method is to check two of nearby values so x(i-1) = 0, x(i)=5 x(i+1)=0, and if checked value is more than 25% bigger or smaller it should be replaced by average of neighborhood.
next example: 0 1 2 3 4 9 6 7 8 <- bad value is 9, and result of my filter should be (4+6)/2 = 5
I've done it using formula node (not 20% and not average, but the point is the same) and it's working but now I want to do it without C and I had lots of problems with memory cause the size of array is 10000.
I attached vi and signal thah you can check that it's working fine
Thanks
Mike
Solved!
Go to Solution.
Attachments:
vi+signal.zip 62 KBMeeHow wrote:
next example: 0 1 2 3 4 9 6 7 8 <- bad value is 9, and result of my filter should be (4+6)/2 = 5
Shouldn't e.g. the value 4 be outside too, because the average of 3 and 9 (=5.5) is more that 25% different to 4?
Here is a quick draft comparing three versions (LabVIEW 8.2):
Your formula node version
the same algorithm in G
Something along the lines you are proposing here.
As you can see, the new idea is not quite satisfactory. It needs more thought. Still, these drafts should give you some ideas how to do it. Modify as needed.
Also your data is similar to a square wave and has these large step functions where the value changes dramatically. These should probably be ignored. Maybe you should look at the first derivative and replace parts where a large positive slope is immediately followed by a negative slope of similar size, for example.
You should also look at absolute steps instead of percentages. If you use percentages and the value is zero, everything is outside, because even 5000% of zero is still zero, right?
LabVIEW Champion . Do more with less code and in less time .
Attachments:
filter testMOD.vi 41 KB -
How to compare the value node of a for-each-group with other for-each-group
Hello!
I have a report in Oracle BI Publisher (10.1.3.2) with several data set. My XML schema is something like
<DATA>
<PARAMETERS>
<MY_PARAMETERS>
<A_ID>12345</A_ID>
<DESCRIPTION>ABC</DESCRIPTION>
<VALUE>111111</VALUE>
</MY_PARAMETERS>
<MY_PARAMETERS>
<A_ID>12345</A_ID>
<DESCRIPTION>DEF</DESCRIPTION>
<VALUE>222222</VALUE>
</MY_PARAMETERS>
<MY_PARAMETERS>
<A_ID>67890</A_ID>
<DESCRIPTION>ABC</DESCRIPTION>
<VALUE>333333</VALUE>
</MY_PARAMETERS>
</PARAMETERS>
<NAMES>
<MY_NAMES>
<A_ID>12345</A_ID>
<NAME>ASDF</NAME>
</MY_NAMES>
<MY_NAMES>
<A_ID>67890</A_ID>
<NAME>EFGH</NAME>
</MY_NAMES>
</NAMES>
<VALUES>
<MY_VALUES>
<A_ID>12345<A_ID>
<VALUE>10987</VALUE>
<DESCRIPTION>ASDFG</DESCRIPTION>
</MY_VALUES>
<MY_VALUES>
<A_ID>12345<A_ID>
<VALUE>26385</VALUE>
<DESCRIPTION>EFGHI</DESCRIPTION>
</MY_VALUES>
<MY_VALUES>
<A_ID>67890<A_ID>
<VALUE>24355</VALUE>
<DESCRIPTION>ASDFG</DESCRIPTION>
</MY_VALUES>
</VALUES>
</DATA>
I'm trying to build a rtf template in Word using this XML schema. The "A_ID" nodes in each group in my data have the same value. I want for each "A_ID" take the respective values in /DATA/VALUES/MY_VALUES.
<?for-each-group:MY_PARAMETERS;./A_ID?>
<?for-each:current-group()?>
<?choose:?><?when: DESCRIPTION='ABC'?>
<?VALUE?>
<?end when?><?end choose?>
<?end for-each?>
<?for-each:current-group()?>
<?choose:?><?when: DESCRIPTION='DEF'?>
<?VALUE?>
<?end when?><?end choose?>
<?end for-each?>
<?/DATA/NAMES/MY_NAMES/VALUE?>
<?for-each-group:/DATA/VALUES/MY_VALUES;./A_ID?>
<?for-each:current-group()?>
<?choose:?><?when: DESCRIPTION='ASDFG'?>
<?VALUE?> <---------------- I obtain for this node the '24355' and '10987' values
<?end when?><?end choose?>
I want to know how to obtain only '24355' value, this is, the value for A_ID (/DATA/VALUES/MY_VALUES) = A_ID (/DATA/PARAMETERS/MY_PARAMETERS).
Can someone help me?CREATE OR REPLACE TRIGGER "TEST_TRG"
BEFORE UPDATE OF "STATUS"
ON "TABLE1"
FOR EACH ROW
BEGIN
IF (:NEW.status = 'HOLD')
THEN
INSERT INTO table2
(status
VALUES (:NEW.status
END IF;
END;You should learn how to write PL/SQL code.
Denes Kubicek
http://deneskubicek.blogspot.com/
http://www.apress.com/9781430235125
http://apex.oracle.com/pls/apex/f?p=31517:1
http://www.amazon.de/Oracle-APEX-XE-Praxis/dp/3826655494
------------------------------------------------------------------- -
Hi All,
I have two tables - TABLE1 & TABLE2 and both the tables are having STATUS column. The requirement is like if the STATUS column of TABLE1 is updated as "HOLD" then the same value has to be updated to the STATUS column of TABLE2.
create or replace trigger "TEST_TRG"
BEFORE
update of "STATUS" on "TABLE1"
for each row
begin
if(:new.STATUS ='HOLD')then
insert into TABLE2 (STATUS)
value (:new.STATUS);
end if;
end;
COMPILATION ERROR:
Compilation failed, line 3 (02:40:14) The line numbers associated with compilation errors are relative to the first BEGIN statement. This only affects the compilation of database triggers.
PLS-00103: Encountered the symbol "{" when expecting one of the following: ( begin case declare exit for goto if loop mod null pragma raise return select update while with <an identifier> <a double-quoted delimited-identifier> <a bind variable> << continue close current delete fetch lock insert open rollback savepoint set sql execute commit forall merge pipe purge The symbol "{" was ignored. Compilation failed, line 7 (02:40:14) The line numbers associated with compilation errors are relative to the first BEGIN statement. This only affects the compilation of database triggers.
PLS-00103: Encountered the symbol "}" when expecting one of the following: ( begin case declare else elsif end exit for goto if loop mod null pragma raise return select update while with <an identifier> <a double-quoted delimited-identifier> <a bind variable> << continue close current delete fetch lock insert open rollback savepoint set sql execute commit forall merge pipe purge The symbol "}" was ignored.
I am getting the compilation errors as above when the trigger is compiled. Can anyone please help me to correct it.
Thanks and Regards,
SuhasCREATE OR REPLACE TRIGGER "TEST_TRG"
BEFORE UPDATE OF "STATUS"
ON "TABLE1"
FOR EACH ROW
BEGIN
IF (:NEW.status = 'HOLD')
THEN
INSERT INTO table2
(status
VALUES (:NEW.status
END IF;
END;You should learn how to write PL/SQL code.
Denes Kubicek
http://deneskubicek.blogspot.com/
http://www.apress.com/9781430235125
http://apex.oracle.com/pls/apex/f?p=31517:1
http://www.amazon.de/Oracle-APEX-XE-Praxis/dp/3826655494
------------------------------------------------------------------- -
How to compare the values of 2 select queires in two diff DB's
Hi,
I need help in building the logic to achieve this :
A program is needed to get reference data from ABC database in ORACLE and update our reference tables with any changes in DEF database in SYBASE.
Pls give me an example where i can compare the select queires from different databases one exsiting in oracle and one in sybase .
Any help will appreciated.
ThanksPLS HELP.
I have no idea on how to do
2) Using your specific requirements, determine how to know if there is a "new row" or a "missing row" or a row , which has a different description
Say Table A in oracle looks like this
Sno Description
1 Out Of Order
2 Shipped
3 Back Order
Say Table B in Sybase looks like this
Type Text
1 Out/Order
2 Shipped
4 Not manufactured
I have to see to that the rows present in Table A in oracle , should be same as rows in Table B in sybase
If not , we have to update , insert and delete the row which is not present in Table A in oracle in Table B in sybase.
In the table example i gave , In the first row of Table B in Sybase , the Text is different from that of Description in Table A for that Sno "1"
So we should update the description.
Row 4 has Sno "4" which is not their in table A , so delete that row from table A.
And In table A , Sno "3" row exists , so we should insert that record in table B.
I know how to query the tables , and get the rows into Result Set ..after that how can i compare and take the steps to update , insert and delete? -
By using Java scripting how can compare database value to Forms value?
i develop portal form n want to compare field that is Issued quantity with available quantity through java scripting.please send me syntax with an example.
problem:
if issued quantity is greater than available Quantity then appear alert message
Thanks,
Sadafthis is the false forum for you. Try it in the database forum e.g.
-
How to compare date values in XQuery
begin
select sysdate into x_date from dual;
select xmlquery( '<A>
{ [b]for $a in ora:view("TableA")
let $id = $a/ROW/ID/text()
where $a/ROW/TRANS_DATE >= x_date
return ..
</A>' returning content}
into temp from dual;
end;
This gives me invalid variable name. I hard code the date and it works fine. I tried xs:date also. Please help.You could use the XQuery function fn:current-dateTime iso trying to use a parameter.
If you want to use an parameter with XQuery, they need to be nodes (not just atomic values) and have to passed using the passing clause.
See the oracle doc for details and examples.
Hth,
Peter -
How to compare pixel values of two different grayscale images...
I have two different grayscale images both of much different sizes. One is 46x20 pixels and the other is 2592x1944 pixels. I'm having trouble finding a way to "scan" the smaller image through the larger one so that comparisons between the pixel values can be made. Basically I'm trying to see if anything matches the smaller image in the big image semi-closely. I can access the pixel values of each image but I can't figure out an algorithm to perform the scan. Any help at all would be very much appreciated! Thanks.
Hi
recipe:
1.
Find all the values for all the pixels in the small image. Some might be similar. Put all those values that are useful into a List called comparisonList.
2.
For each scanline in the large image
For each pixel in the scanline
is this pixel the same value as a pixel in the comparisonList?
if so do something
is the scanline finished?
if not next pixel
loop to next scanline
where scanline is a horizontal line in the big picture.
my 2c
hope helps
Maybe you are looking for
-
Problems with partitioning and install Grub. Fresh install
All, First post here. I appreciate any help you can offer. I am having some problems when installing Arch Linux. I am installing Arch on a brand new (3 days old) Toshiba SatelliteC655D-S5300 Laptop. Hot sheet can be found at http://cdgenp01.csd.toshi
-
Process InfoPackage based on a condition in Process Chain
Hi, I would like to include a Function Module in my Process Chain.Based on the output of the Function Module (example Flag - 'A','B','C') I would like to load data from Infopackage. Could you please suggest the best possible solution. Thanks, Nimai
-
ITunes keeps deleting my library
When I launch iTunes i get an error stating that my iTunes library is damaged and then deletes all my movies, music and podcasts from the library. If I plug my ipod in iTunes then deletes everything from it. This is driving me to insanity!!! Can anyo
-
Suppress leading spaces while displaying an amount field in a Smart form
Hi all, In a smart form, I am using fields like KONV-kbetr and VBAP-netwr each of them currency type and 2 decimal places. I want to suppress the decimal places and also the leading spaces while displaying these fields in a smartform cause when this
-
Hello Everyone, I am reviewing our failed integration in SUS and have noticed that most of the purchase orders not transmitted to SUS has encountered the following errors: a) Error in an XI interface: Exception occurredE:AM:219 -Enter a postal code E