How to compare dates
I have a db access with a field called 'walkDate '.Dates stored in this area are in the date format short j/yyyy.
I want to run a query to search for results where walkDate is the date of the valid form.
Dates of form are submitted in dd/mm/yyyy, but can't find my request date (I know that it exists).
If I simply query the db and do return the results of the walkDate field, it will return d/m/YYYY format 00:00:00.
Why - what is returns a date ODBC? and how can I compare dates? I compare the pieces separately?
Fortunately for you, since walkDate is a date field and not a text field, access format is irrelevent.
Since the dates are also components, you must take those into account when comparing. One way to do that is,
Select somefields
of sometables
where walkDate > = #createodbcdate (form.date) #.
and walkDate< #createodbcdate(dateadd("d",="" 1,="">
This is the general idea. You must do something to ensure that form.date is really a date of course.
Tags: ColdFusion
Similar Questions
-
How to compare date in different tables?
I have 2 tables with the same structure
create table (Atb)
col1 char (5),
col2 char (5),
COL3 char (5),
date of sign_date);
create table (Btb)
col1 char (5),
col2 char (5),
COL3 char (5),
date of vote_date);
the data in the Atb and Btb tables are the same for the 3 columns col1, col2 and col3. How can I compare the sign_date and the vote_date?
Thank you!
Thanks Frank. the answer solves my problem!
-
Hello experts...
I'm new to this forum and Oracle coding complex.
I have a task in which I want to compare two tables with the same structure, same columns. My Oracle database is 11g Release 2. I want this column-by-column comparison and save the result in a separate table. (say result_table)
The structure of the table would be as follows:
SQL > desc emp;
Name Null? Type
----------------------------------------- -------- ----------------------------
EMPNO NOT NULL NUMBER 4
ENAME VARCHAR2 (10)
JOB VARCHAR2(9)
MGR NUMBER(4)
HIREDATE DATE
SAL NUMBER(7,2)
COMM NUMBER(7,2)
DEPTNO NUMBER (2)
SQL > emp_comp desc;
Name Null? Type
----------------------------------------- -------- ----------------------------
EMPNO NOT NULL NUMBER 4
ENAME VARCHAR2 (10)
JOB VARCHAR2(9)
MGR NUMBER(4)
HIREDATE DATE
SAL NUMBER(7,2)
COMM NUMBER(7,2)
DEPTNO NUMBER (2)
Both of the tables EMPNO is the primary key.
I want to compare these two tables based on the EMPNO (EMPNO even is both tables).
The result log table would be as follows:
SQL > create table result_table
2 (check_sr_no, number (5),)
table_name 3 varchar2 (30),
ROW_ID 4 varchar2 (20).
column_name 5 varchar2 (20).
6 column_data varchar2 (1000).
compared_by 7 varchar2 (10));
Table created.
SQL > alter table result_table
2 Add the constraint result_table_pk
3 primary key (check_sr_no);
Modified table.
The name of the table and the name of the column will not be hardcoded (based parameter by user)
I tried to use the dbms_comparison package, but do not find comparison of column to column.
I also used by using the query operator LESS. It's showing the difference in rank.
I also went to https://asktom.oracle.com/pls/apex/f?p=100:11:0:P11_QUESTION_ID:2151582681236
Your help will be very appreciated.
Thank you
DK
Tom Kyte has answered this question MANY times over the years. Here are links for its solution
https://asktom.Oracle.com/pls/Apex/f?p=100:11:0:P11_QUESTION_ID:4934799800346640847
-
How to compare two dates and find exactly
How to compare two dates and find the exact age of the person, no one could be an age of child 2 days or a month, or other.
I'd really appreciate if someone help o
Concerning
After spending 2 hours, I go out with a solution by myself, how ever the function can be customize to check if the user enters date right.
function findAge(subjectName,fromdate, todate) { console.log("findAge(fromdate, todate) is called now "+subjectName+"-->"+fromdate+"-->"+todate); if(todate) todate= new Date(todate); else todate= new Date(); var age= [], fromdate= new Date(fromdate), y= [todate.getFullYear(), fromdate.getFullYear()], ydiff= y[0]-y[1], m= [todate.getMonth(), fromdate.getMonth()], mdiff= m[0]-m[1], d= [todate.getDate(), fromdate.getDate()], ddiff= d[0]-d[1]; if(mdiff < 0 || (mdiff=== 0 && ddiff<0))--ydiff; if(mdiff<0) mdiff+= 11; if(ddiff<0){ fromdate.setMonth(m[1]+1, 0); ddiff= fromdate.getDate()-d[1]+d[0]; --mdiff; } if(ydiff> 0) age.push(ydiff+ ' year'+(ydiff> 1? 's ':' ')); if(mdiff> 0) age.push(mdiff+ ' month'+(mdiff> 1? 's':'')); if(ddiff> 0) age.push(ddiff+ ' day'+(ddiff> 1? 's':'')); if(age.length>1) age.splice(age.length-1,0,' and '); console.log("==============================="); console.log("Subject age is = "+age.join('')); console.log(" age Day = "+ddiff); console.log(" age Month = "+mdiff); console.log(" age Year = "+ydiff); console.log("==============================="); var subjectAGE = age.join(''); }
peardox Thanks for the reply
-
Please, tell me how to compare between the field two Nina in the date format?
There is a script in this format, which takes the beginning and end of treatment records.
--=========
SELECT (SELECT MIN (start_TIME)
OF APP_HISTORY HPA
WHERE APH. APPLICATION_FK IN
(SELECT APP.ID
OF THE APP APPLICATION
WHERE APP. APPID = "D4TEST4NMA-19'.
)
) start_app,.
(SELECT MAX (end_TIME)
OF APP_HISTORY HPA
WHERE APH. APPLICATION_FK IN
(SELECT APP.ID
OF THE APP APPLICATION
WHERE APP. APPID = "D4TEST4NMA-19'.
)
) end_app
DOUBLE;
--=========
To calculate how much time between the beginning and the end of the treatment required in order to to deal with in the time format "dd.mm.yyyy hh24:mi:ss.Tips
1 you have a relational database. Relational databases address tables, lines and columns. No fields. There are no fields in any RDBMS
2 the unit of a DATE column is a DAY
3 you can add and subtract two DATE columns, the result will be in DAYS
4 allows you to convert that number to any other unit by making a date has 24 * 60 minutes and 24 * 60 * 60 seconds.------------
Sybrand Bakker
Senior Oracle DBA -
How to compare, present value: block.text_item with the value of data
Hello
Could you please tell me
How to compare the current value: block.text_item with the corresponding database column value.
I use form 10g
It has block and there is a text element in this block.
When I run the form and query the block (in a table), the: block.text_item show me any value it in the database.
Now I add value in the: block.text_item to the existing value.
now
the: block.text_item contains the old + new added value
While
the database table contains the value 'old '.
Now, with a click of button, I want to know what value I added
Please can you me, is it possible without writing a select query?Hello
Now, with a click of button, I want to know what value I added
So you're saying always user will bring added value to the existing value. Because it will fail in a case. Let's say that
Database value is = ABCD
The user opens the form and he took the D and write E and now value is ABCE and length is always the same 4. There is therefore no need to add.In any case, you can know that the value of database at run time, there is a property for the element called DATABASE_VALUE. She gives the value that is in the database while you run the form before save. and you can use it like that...
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 that's clear.
-Clément
-
I'm using labview 7.1 and I have problems to compare data on two spreadsheet with about 30 + data and also have problems of data backup on the same excel worksheet. Like after comparing, I want to add value to the next column to _result.xls. This is joint vi. Hope someone can give me some ideas how to do this.
-
HOW to compare timings in plsql?
Hello everyone,
My problem is
see my column name is DLY_TIMINGS which is used to store the timings form
11:00 - 13:00
who is of varchar2 data type
I know it's maybe wrong way to store but can't help in this project happens 5 years
My requirement is to see my below code display Yes when the time already exist in the table
for example, 13:00 is between 23:00 to 13:00
but I am unable to think of how consider 30 minutes also it is 13:30
who should view not because there is no
Please help on this
create the table test8
(
DLY_TIMINGS varchar2 (20)
)
insert into test8 values (' 11:00 - 13:00 ');
DECLARE
l_bsttm NUMBER;
l_bentm NUMBER;
l_bstmd VARCHAR2 (5);
l_benmd VARCHAR2 (5);
l_cstmd VARCHAR2 (5);
l_cenmd VARCHAR2 (5);
l_exists number: = 0;
BEGIN
l_bsttm: = to_number (SUBSTR('01:30',1,2));)
l_bentm: = to_number (SUBSTR('02:00',1,2));)
l_bstmd: = "PM";
l_benmd: = "PM";
If l_bstmd = "PM" then
l_bsttm: = l_bsttm + 12;
end if;
If l_benmd = "PM" then
l_bentm: = l_bentm + 12;
end if;
SELECT COUNT (*)
in l_exists
OF TEST8
WHERE l_bentm > = (case when SUBSTR (DLY_TIMINGS, 7, 2) = "PM" THEN
TO_NUMBER (substr (DLY_TIMINGS, 1, 2)) + 12
To_number (SUBSTR(DLY_TIMINGS,1,2)) end ELSE)
and l_bsttm < = (case when SUBSTR (DLY_TIMINGS, 16, 2) = "PM" THEN
TO_NUMBER (substr (DLY_TIMINGS, 10, 2)) + 12
To_number (SUBSTR (DLY_TIMINGS, 10, 2)) of OTHER purpose);
If l_exists > 0 then
dbms_output.put_line ('yes');
on the other
dbms_output.put_line ('no');
end if;
end;
Hello
Use dates to compare dates. Then all first convert your limits of time and dates, and then you can do all that:
WITH sample_data AS (SELECT "11:00 - 13:00 ' str FROM DUAL");
time_bounds AS (SELECT TO_DATE (REGEXP_SUBSTR (str, ' [^-] +'), ' Hh: mi AM ') (EDT) 1,)
To_date (REGEXP_SUBSTR (str, ' [^-] +', 1, 2), "Hh: mi AM") time2
OF sample_data
)
SELECT BOX WHEN to_date (' ' 13:00 ', ' HH: mi AM ') between (HAE) 1 and 2 then 'no yes' elsewhere ' ' end,
CASE WHEN to_date (' ' 13:30 ', ' HH: mi AM ') between (HAE) 1 and 2 then 'no yes' elsewhere ' ' end
OF time_bounds;
-
How to compare premises, iSCSI and storage NFS for VMware ESXi 5 with IO Analyzer?
Hello
I have 2 hosts ESXi 5.0 with a few virtual machines running. I would compare the IO throughput for my local storage, iSCSI and NFS vmware storage store. Can someone point me to the right direction? I read the documents and tutorials, but I'm not sure how to compare tests from these 3 options.
I have a need to compare the following storage options.
Local disk on the ESX host
iSCSI on QNAP NAS device
iSCSI on EMC e 3100
NFS on QNAP NAS device
NFS on EMC e 3100
IOmeter seems to be good tool based on reading, but still not clear where to make changes to pass tests of storage to another.
Thanks in advance,
Sam
If you use IO monitor, then you must simply vmotion the VMS to the data store for the device you want to test, and then run the test (and Records results). Can vmotion for the following data store and repeat.
-
How to compare two lines in PL/SQL?
Hi all
How to compare two lines in PL/SQL? Is there a method I can use to compare their column by column instead?
Any comments would be much appreciated.PhoenixBai wrote:
By lines I mean, two rows of the same table!Ah, finally, we get a bit more useful information
and I need to compare the column by column to see if there is a difference between these two rows.
Like this, you mean?
SQL> ed Wrote file afiedt.buf 1 with data as (select 1 as id, 'A' as dta, 'B' as dta2 from dual union all 2 select 2, 'A', 'B' from dual union all 3 select 3, 'B', 'C' from dual) 4 -- 5 ,chk as (select &id1 as id1, &id2 as id2 from dual) 6 -- 7 select case when ( 8 select count(*) 9 from ( 10 select dta, dta2 11 from data, chk 12 where id = id1 13 minus 14 select dta, dta2 15 from data, chk 16 where id = id2 17 ) 18 ) = 0 then 'No Difference' 19 else 'Difference' 20 end as check_result 21* from dual SQL> / Enter value for id1: 1 Enter value for id2: 2 old 5: ,chk as (select &id1 as id1, &id2 as id2 from dual) new 5: ,chk as (select 1 as id1, 2 as id2 from dual) CHECK_RESULT ------------- No Difference SQL> / Enter value for id1: 1 Enter value for id2: 3 old 5: ,chk as (select &id1 as id1, &id2 as id2 from dual) new 5: ,chk as (select 1 as id1, 3 as id2 from dual) CHECK_RESULT ------------- Difference SQL>
My only concern is the result of this sql. East - reliable? It can really be used to differentiate the two lines? I mean, the result would be the same, as I do with Java?
Not sure what you mean by "reliable"? SQL is not some kind of generator of random result (by derogation from the use of the DBMS_RANDOM package). If you ask him if 1 + 1 = 2, then it will always give you the right answer.
-
How to compare in Where clause
Hello
I need help comparing the value in where clause
There is a table called productivity which has columns as
OBJECT_TYPE, COMPLEXITY, OBJECTIVE
Now my requirement is I have a query like this
SELECT
PRO. PROJECT NAME,
POBJ. OBJECT_NAME,
POBJ.COMPLEXITY,
PRO. EFFORT
Of
PROJECT PRO, PROJECT_OBJECTS POBJ
WHERE
PRO.ID = POBJ.ID
I have to compare data between the effort of columns in the query and target in the table of productivity
SELECT
PRO. PROJECT NAME,
POBJ. OBJECT_NAME,
POBJ. OBJECT_TYPE,
POBJ.COMPLEXITY,
PRO. EFFORT
Of
PROJECT PRO, PROJECT_OBJECTS POBJ
WHERE
PRO.ID = POBJ.PRO_ID
now I change the query to compare
SELECT
PRO. PROJECT NAME,
POBJ. OBJECT_NAME,
POBJ.COMPLEXITY,
-case when
POBJ. OBJECT_TYPE IN (SELECT OBJECT_TYPE OF PRODUCTIVITY) AND
POBJ.COMPLEXITY (SELECT COMPLEXITY OF PRODUCTIVITY)
PRO. EFFORT > (SELECT GOAL OF PRODUCTIVITY WHERE type_objet =? AND
COMPLEXITY =? ) / / here instead of? I have to say
POBJ. OBJECT_TYPE and POBJ.COMPLEXITY
then
10
ON THE OTHER
0
END "Effort."
Of
PROJECT PRO, PROJECT_OBJECTS POBJ
WHERE
PRO.ID = POBJ.PRO_ID
How to specify this POBJ column. OBJECT_TYPE and POBJ.COMPLEXITY in please of? I put please suggest.
Is there a way where we can spend the value of POBJ. OBJECT_TYPE and POBJ.COMPLEXITY to a variable binding and select it in the where clause
Indicate please let me know if this issue is not understood.
Thank you
SudhirSomething like that, maybe?
SELECT PRO.PROJECT_NAME, POBJ.OBJECT_NAME, POBJ.COMPLEXITY, case when PRO.EFFORT > PROD.GOAL then 10 ELSE 0 END "Effort" FROM PROJECTS PRO, PROJECT_OBJECTS POBJ, PRODUCTIVITY PROD WHERE PRO.ID = POBJ.PRO_ID AND POBJ.OBJECT_TYPE = PROD.OBJECT_TYPE (+) AND POBJ.COMPLEXITY = PROD.COMPLEXITY (+)
I did an outer join; don't know if that's what you want - if not, just get rid of the (+) {noformat} {noformat}
-
How to erase data from the iphone if I lost and iphone is offline
How to erase data from the iphone if I lost and iphone is offline
< post branched out by host >
Hello
What to do if your iOS device is turned off or offline?
If your missing device is turned off or offline, you can still implement this Mode lost, lockor remote wipe. The next time your device is online, these measures will take effect. If you remove the device from your account while it is offline, pending actions for the device will be cancelled.
If your iPhone, iPad or iPod touch is lost or stolen - Apple supports
-
How display the date of my last update of OSX in my Mac?
How display the date of my last update of OSX in my Mac?
If it was in the last 30 days, the updates will often (not always) show the Mac App store on your page of updates, under the heading "updates installed in the last 30 days.
-
How to delete data from the iPhone 5 c?
How to remove data from my iPhone 5 c?
What do you mean by data? Applications, photos, music?? It depends on what you're trying to delete.
-
How to display date / time in the browser console?
How to display date / time in the browser console?
You can set through the Options (gear icon) page in the Web Console (Firefox/tools > Web Developer).
This applies to the browser console and the Web console.
Maybe you are looking for
-
Can I replace the optical drive of the ENVY 15 t-k000 with a hard drive?
Hello!! I just got the HP ENVY 15 t-k000 http://www.shopping.hp.com/en_US/home-office/-/products/Laptops/HP-ENVY/G0T95AV?HP-ENVY-15t Can I replace the optical drive with an SSD (for example, Seagate 600 240 G)? Thank you! I saw there are several vide
-
Return to windows 7 after upgrading to Windows 10
I had upgraded my legal version of Win 7 to Win 10, but could never find a contact with my WiFi router which worked very well under Win 7. I tried a bunch of suggestions, but without success. I started again to Win 7 and the system works well, but
-
The taskbar on my laptop won't 'hide' when this option is selected.
* Original title: taskbar The taskbar on my laptop won't 'hide' when this option is selected. How to fix?
-
Windows 7 works only with canon MX 340
Canon MX 340 printer works only with windows 7.
-
My trackpad settings back.
my hp envy 6 ultrabook is infected with a virus and a file system is infected so the OS crashes. I reinstalled windows 7 but now I've lost my trackpad for example settings: two fingers scrolling, switching on or off, trackpad brief, any settings that