Groovy Script to find the difference between Dates
I am trying to build a script that takes a date from a RequestField and calculates the number of days between this date and the current date (from session).
So far, I have a problem, the analysis to-date from the RequestField chain. I found this code but it doesn't seem to work...
date = new Date().parse('yyyy/MM/dd', '1973/07/09')
I get the following error...
Error Message: groovy.lang.MissingMethodException: No signature of method: java.util.Date.parse() is applicable for argument types: (java.lang.String, java.lang.String) values: {"yyyy/MM/dd", "1973/07/09"}
Any help would be greatly appreciated.
Hello
What version of server? The extract you have here works fine on mine (563).
This also works for me
new java.text.SimpleDateFormat('yyyy/MM/dd').parse('1973/07/09')
See you soon
Nils
Tags: Dell Tech
Similar Questions
-
Find the difference between two date and time
Hi friends,
I wanted to find the difference between two date and time, but my qury is slightest error "invalid number."
select sql_step_num,proc_name,run_seqno,start_date,end_date,(to_char(start_date,'HH24-MI-SS') - to_char(end_date,'HH24-MI-SS') ) as ed from eval.EVAL_RUNTIME_DETAILS where trunc(start_date) = trunc(sysdate) order by sql_step_num;
You try to get the feel between two char strings.
And more difference between two dates gives a NUMBER of days.
Try this:select sql_step_num,proc_name,run_seqno,start_date,end_date,numtodsinterval(end_date-start_date,'DAY') as ed from eval.EVAL_RUNTIME_DETAILS where trunc(start_date) = trunc(sysdate) order by sql_step_num;
-
How to find the difference in date in years, months and days
Hello
I need to find the difference between 2 dates in the following way "years months days". "
Please can help me, how can I achieve this.
for example, in the scott schema emp table, I need to find the difference in date between sysdate and hiredate for an employee in the following way.
12 years 7 months 4 days.Hello
Please, see this post to AskTom [difference between 2 dates | http://asktom.oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:96012348060]. There is good information in this forum, for example you can also see this thread [calculation of years, months & days | http://forums.oracle.com/forums/thread.jspa?messageID=3115216]
Kind regards
Published by: Walter Fernández on November 30, 2008 08:58 - adding another link
-
Find the difference between two numbers (DBL)
Hi all
Is there a function in labview other than the subtraction function that can find the difference between the two numbers given?
Thank you
Davidson
-
How to find the difference between standard edition and standard edition one
How to find the difference between oracle database standard edition and standard edition one 64 bit
(a) using sql
(b) using the configuration/installation filesHow to find the difference between oracle database standard edition and standard edition one 64 bit
(a) using sql
Select * the option of $ v;
(b) using the configuration/installation files
opatch lsinventory-details
-
How to find the difference between two dates in time except Sunday
Hi all
I have a table, as shown below.
I would like to know the difference between same tr_ids create_time, which should give out in hours except Sunday.SQL> select * from test; TR_ID CREATE_TIME CODE -------------------------------------------------- --------------------------------------------------------------------------- ---------- S12341 05-JUN-12 12.20.52.403000 AM 1003 S12342 11-JUN-12 11.15.33.182000 AM 1003 S12342 07-JUN-12 12.00.36.573000 PM 1002 S12343 20-JUN-12 12.34.37.102000 AM 1003 S12343 15-JUN-12 11.34.27.141000 PM 1002 S12344 01-JUL-12 10.01.06.657000 PM 1002 S12344 06-JUL-12 12.01.04.188000 AM 1003 S12341 31-MAY-12 11.20.38.529000 PM 1002
For example:
TR_ID: S12344
1002_Create_time: July 1, 12 PM 10.01.06.657000 (i.e. Sunday)
1003_Create_time: 12.01.04.188000 AM 6 July 12
1002 create time is 22:00 Sunday.
If the query must exclude only the hours of Sunday which is 10 p.m. to Monday 00 h which is 2 Hrs.
I tried the sub query after doing a search on this forum but I am not getting the desired output.
Need help to get the desired o/pSELECT count(*) FROM (SELECT ROWNUM RNUM,tr_id,create_time CT_1002 FROM test c WHERE c.tr_id='S12344' and ROWNUM <= (select (cast(a.create_time as date)-cast((select create_time from test b where a.tr_id=b.tr_id and code=1002) as date)) from test a where a.code=1003 and a.tr_id=c.tr_id) + 1) d WHERE to_char(cast((select create_time from test e where e.tr_id=d.tr_id and code=1002) as date) + RNUM - 1, 'DY') NOT IN('SUN');
Hello
If I unederstand the problem correctly, that's what you want:
WITH got_extrema AS ( SELECT tr_id , CAST (MIN (create_time) AS DATE) AS start_date , CAST (MAX (create_time) AS DATE) AS end_date FROM test GROUP BY tr_id ) SELECT tr_id , start_date, end_date -- If wanted , 24 * ( ( ( TRUNC (end_date, 'IW') -- Count -1 day for every full week - TRUNC (start_date, 'IW') ) / -7 ) + LEAST ( end_date -- If end_date is a Sunday , TRUNC (end_date, 'IW') + 6 -- consider it 00:00:00 on Sunday ) - CASE WHEN start_date >= TRUNC (start_date, 'IW') + 6 -- If start_date is a Sunday THEN TRUNC (start_date, 'IW') + 6 -- consider it 00:00:00 Sunday ELSE start_date END ) AS total_hours FROM got_extrema ;
I guess that you don't need to worry about fractions of a second. As you did in the code you have posted, I am to convert the TIMESTAMP to date values, because of DATE arithmetic and functions are so much better than what is available for timestamps.
Basically, it's just to find the number of days between start_date and end_date and multiplying by 24, with these twists:
(a) 1 day is deducted for each week between start_date and end_date
(b) if End_date is a Sunday, none of the end_date himself hours are counted
(c) If start_date is a Sunday, then all the start_date himself hours are counted. Why these hours should be counted? Because 1 day is already being deducted for the week which includes start_date, which contains only this Sunday.TRUNC (dt, 'IW') is the beginning of the ISO week containing dt; in other words, 00:00:00 the or before the dt last Monday. This is not the NLS parameters.
Of course, I can't test without some sample data and the exact results you want from these data. You may need a little something more If start_date and end_date are both on the same Sunday.
Whenever you have a problem, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) of all of the tables involved.
Also post the results you want from this data, as well as an explanation of how you get these results from these data, with specific examples.
Always tell what version of Oracle you are using.
See the FAQ forum {message identifier: = 9360002} -
How to find the difference between two dates in the presentation layer
Hi gurus,
Hello to everyone. Today, I came with the new requirement.
I need to know the difference between a date and the current date in the formula column application presentation layer.by.
Thank you and best regards,
PratesHi Navin,
TIMESTAMPDIFF function first determines the timestamp component that corresponds to the specified interval setting. For example, SQL_TSI_DAY corresponds to the day component and SQL_TSI_MONTH corresponds to the component "month".
If you want to display the difference between two dates in days using SQL_TSI_DAY, unlike butterflies SQL_TSI_MONTH and so on...
hope you understand...
Award points and to close the debate, if your question is answered.
See you soon,.
Aravind -
Simple query to find the difference between 2 numbers in one column to another column
Hello
I would like to know the difference between 2 numbers in same column corresponding to a condition of another column. How do that?
For example: say I have a table with 3 columns A, B and C.
A > Varchar2
B > Varchar2
C > number
A B C A D 1 B C 2 C B 3 D A 4 I want something like 'column value corresponding C min min (col B) result = (col A) - value of the corresponding C column (number)' without having to write 2 select statements. How do I do that?
Thanks in advance
aBBy007
Notes on the system:
2-node 11.2.0.3.4 GI/RDBMS running on RHEL5.
Hello
It is not very similar to your original question. It would be better if you asked what you really want in your first post, rather than making people to time writing solutions you want not and can not use waste. Once you see an answer to this question, will you change the question again?
Here's a way to do what you asked:
WITH got_lasts AS
(
SELECT val.thread #.
, MAX (val.sequence #) AS last_standby_seq_received
MAX (CASE
WHEN val.applied = "YES".
THEN val.sequence #.
END
) AS last_standby_seq_applied
V $ archived_log val
Join v$ database vdb WE val.resetlogs_change #.
= vdb.resetlogs_change #.
GROUP BY thread #.
)
SELECT thread #.
last_standby_seq_received
last_standby_seq_applied
last_standby_seq_received
-last_standby_seq_applied AS total_lag
OF got_lasts
ORDER BY thread #.
;
-
How to find the difference between the two timestamp columns
Dear all,
Please solve my problem,
I have Table name of the folder that has the following columns,
EmpID in the number column, timestamp dat
who has the following values
Expand | Select | Wrap | Line numbers
EmpID dat
====== ====
101 4/9/2012 09:48:54
101 4/9/2012 09:36:28
101 4/9/2012 18:16:28
101 4/10 / 2012 09:33:48
101 4/10 / 2012 12:36:28
101 4/10 / 2012 20:36:12
101 4/11 / 2012 09:36:28
101 4/11 / 2012 16:36:22
Here, I need to display the following columns
EmpID, min (DAT) as start, max (dat) as end and difference (max (dat) - min (dat) for each day,
for example,.
End difference EmpID Strart
101 4/9/2012 09:48:54 09/04/2012 18:16:28 8.28
Like this.
3 days different here is so it should return 3 discs with the mentioned columns above,
Please help me find it.
Thank you
Kind regards
Gurujothi
Published by: Gurujothi on April 25, 2012 04:45Gurujothi wrote:
Dear Alex,
Thank you for your reply,
Depending on whether you are your quesy showing it in hour and minutes format its right but you mention all rows of the query
If the table has more than 3000 lines then how it is possible to write this much higher request,
my table with almost 3500 lines.You can make a few changes in the above query I posted the last I mentioned?
Thank you.
Published by: Gurujothi on April 25, 2012 23:18
Hello
You don't need to write whole records 3000 it... alex just wrote that for example have no table as your table...
so just use the under part of this query as in the previous post, alex:select empid, trunc(dat), min(dat) as start_dat, to_char(min(dat), 'hh24:mi:ss') as start_dat_part, max(dat) as end_dat, to_char(max(dat), 'hh24:mi:ss') as end_dat_part, max(dat)-min(dat) diff, to_char(max(dat)-min(dat), 'hh24:mi:ss') diff_part, extract(day from max(dat)-min(dat)) || ' days' || ':' || extract(hour from max(dat)-min(dat)) || ' hours' || ':' || extract(minute from max(dat)-min(dat)) || ' mins' || ':' || extract(second from max(dat)-min(dat)) || ' sekas' from trans group by empid, trunc(dat)
hope this fixes your need
-
How to find the difference between related areas
Hi all
My problem is I have a table in which each woman will be visited maximum 8 times, each woman may or may not
given a reference in any visit which in turn women will respond to this referral in a next visit
(not necessarily the next visit), I need to calculate the average number of visits between the visit
in which the wife received a refferal and visit in which she responds.
as an example
woman_id visit_id given_referral respond_to_referral
-------- -------- -------------- -------------------
1 1 TRUE NULL
1 2 TRUE TRUE
1 3 TRUE NULL
1 4 TRUE NULL
1 5 NULL NULL
1 6 TRUE NULL
This means that visit 2 response is referral to visit 1 so the difference is 1.
and the visit 6 response corresponds to the referral in visit 4 so the difference is 4.
what I can't do is knowing how to know answer to visit 6 associated reference visit 4 No 1 or 2 or 3...
and I need to find the following table of the foregoing
woman_id difference between referral and response
--------- ---------------------------------------
1 1
1 2
quick access to help please
Published by: M.Jabr on December 14, 2009 08:05with t as ( select 1 woman_id,1 visit_id,'TRUE' given_referral,NULL respond_to_referral from dual union all select 1,2,'TRUE','TRUE' from dual union all select 1,3,'TRUE',NULL from dual union all select 1,4,'TRUE',NULL from dual union all select 1,5,NULL,NULL from dual union all select 1,6,NULL,'TRUE' from dual ) select woman_id, diff from ( select woman_id, visit_id - last_value(case when given_referral is not null then visit_id end ignore nulls ) over( partition by woman_id order by visit_id rows between unbounded preceding and 1 preceding ) diff, respond_to_referral from t ) where respond_to_referral = 'TRUE' / WOMAN_ID DIFF ---------- ---------- 1 1 1 2 SQL>
SY.
-
Script to determine the days between dates
I'm totally new to JavaScript. I try to do a calculation with a custom calculation script field. I tried to restore something with script I have checked in several forums, but not completely succeeded. I have 4 form fields. 2 date fields, a body of numbers (formatted for currency) and the field of computing. The calculation I'm trying is ((365-(jours entre les 2 champs de date)) divided by 365) times (currency field). Any help would be greatly appreciated.
Event.value = () ((365-(xdays)) / 365) * (this.getField("premium1").value) ) .toFixed (3)
Thank you for the offer, but a donation is not required. We can still be friends. Send me a mail to [email protected] if you want...
-
Hello
I get 2 different types of data from the controller. How to differentiate b/w them.
After receiving my code in deccissions. There are 6 different control elements in my project attached to the controller. Thanks for give me idea how I send data to the controller for this controller to differentiate that exit to be active or low
First, look at the couple of serial examples that come with LabVIEW. You use the VISA functions to read and write. Your technique to separate the values will work as well in LabVIEW. You would be to convert the string returned by VISA reading to a digital (i.e. with the Scan of the chain). Then do the comparison, then the result of wire to one of the two indicators. Put the terminal of each indicator inside a case statement would be a way to do it.
-
How to store the difference between two timestamps as a number?
Hello
I need to find the difference between 2 variables of timestamp and the result will be stored as a number in minutes?
as
declare
timestamp (7) of the fir_timestamp: = 1 January 2012 13:30 ';
timestamp (7) of the sec_timestamp: = 1 January 2012 14:00 ';
c number;
Start
c:=((sec_timestamp-fir_timestamp)/(24*60));
dbms_output.put_line (c);
end;962813 wrote:
declare-fir_timestamp timestamp (7): ='01 - jan - 2012 13:30 ';
timestamp (7) of the sec_timestamp: = 1 January 2012 14:00 '; Incorrect type declarationfir_timestamp timestamp: = 1st January 12 01.30.00.000000 PM';
sec_timestamp timestamp: = 1st January 12 02.00.00.000000 PM';
c number;
Start
c: = ABS ((extrait (HEURE de sec_timestamp) - extract (fir_timestamp TIME)) * 60) +.
ABS ((extrait (MINUTE de sec_timestamp) - extract (fir_timestamp MINUTE)));
dbms_output.put_line (' interval Min Total:-' | c);
end;
/
declare
*
ERROR on line 1:
ORA-01830: date format picture ends before converting all of the input string
ORA-06512: at line 6Follow what Paul has done...
In fact, you do not need timestamp, date data type is enough
SQL> declare 2 fir_timestamp date := 3 to_date('01-jan-2012 13:30:00','dd-mon-yyyy hh24:mi:ss'); 4 sec_timestamp date := 5 to_date('01-jan-2012 14:00:00','dd-mon-yyyy hh24:mi:ss'); 6 c number; 7 begin 8 c:= round((sec_timestamp-fir_timestamp)*24*60); 9 dbms_output.put_line(c); 10 end; 11 / 30 PL/SQL procedure successfully completed.
If you want to place on timestamp
SQL> declare 2 fir_timestamp timestamp := 3 to_timestamp('01-jan-2012 13:30:00','dd-mon-yyyy hh24:mi:ss'); 4 sec_timestamp timestamp := 5 to_timestamp('01-jan-2012 14:00:00','dd-mon-yyyy hh24:mi:ss'); 6 c number; 7 begin 8 c:= round(( 9 to_date(to_char(sec_timestamp,'ddmmyyyyhh24miss'), 10 'ddmmyyyyhh24miss')- 11 to_date(to_char(fir_timestamp,'ddmmyyyyhh24miss'), 12 'ddmmyyyyhh24miss') 13 )*24*60); 14 dbms_output.put_line(c); 15 end; 16 / 30
-
code succcessive to genereate difference between dates in a table
First create and insert statements;
The output of the table of the ANNEX should be now like this:create table schedule(iloan_code number , schedule_date date); insert into schedule values(1001, to_date('01-jun-2012')); insert into schedule values(1001, to_date('01-jul-2012')); insert into schedule values(1001, to_date('01-aug-2012')); insert into schedule values(1001, to_date('01-sep-2012')); insert into schedule values(1001, to_date('01-oct-2012')); commit;
We want an additional column by name as well as the existing columns DAYS that would be the difference between dates.ILOAN_CODE SCHEDULE_DATE 1001 01-JUN-12 1001 01-JUL-12 1001 01-AUG-12 1001 01-SEP-12 1001 01-OCT-12
First line should be the difference between sysdate as well as the date of June 1, 2012 and successive lines must be the difference between successive calendar date
For example in the second row the DAYS column should represent the difference between 1 July 2012 and 1 June 2012 and so on for the following ranks too.
We need get the result by a SELECT statement
The output of the table in the ANNEX must be something like that.
Please notify;iloan_code schedule_date days Logic which we need 1001 1-Jun-12 22 sysdate-1st June 2012 1001 1-Jul-12 30 difference between 1st July 2012 and 1st June 2012 1001 1-Aug-12 31 difference between 1st aug 2012 and 1st July 2012 1001 1-Sep-12 31 difference between 1st sep 2012 and 1st aug 2012 1001 1-Oct-12 30 difference between 1st oct 2012 and 1st sep 2012
Hello
You can change the Hoek solution like this:
SELECT iloan_code , schedule_date , schedule_date - LAG ( schedule_date , 1 , TRUNC (SYSDATE) ) OVER (ORDER BY schedule_date) AS days_between FROM schedule ORDER BY schedule_date ;
If all schedule_dates will be after SYSDATE, then you need not the CASE expression to test if it is.
The argument optional 3rd to LAG is a return value in case there is no previous line.Sri says:
... The output of the table in the ANNEX must be something like that.iloan_code schedule_date days Logic which we need 1001 30-Jun-12 07 sysdate-30June 2012 1001 1-Jul-12 30 difference between 1st July 2012 and 30 June 2012 ...
The difference between 30 June 2012 and July 1, 2012 is not only 1 day?
-
Do not understand the difference between my models and why they are distributed differently
I converted a bunch of guest in model systems and I have now a few top group and listed on sub Discover Virtual machines but also have other models in alphabetical order among the guest computers.
I need know how to find the differences between these models (there are) and why
they are arranged in this way?
I have attached a picture of my layout, note both models circled were created from the same guest machine and the content seems to be the same. My host is vSphere ESXi 4.
Thank you
Andy
andykam wrote:
The hosts and clusters discovered I model right click and select Convert to template. But have listed it under default, after the model to select the virtual machine that is discovered in the wizard. Otherwise, it gets partner and alphabetical?
exactly
Maybe you are looking for
-
What virus should be concerned
I just had MacKeeper pop - up and say that I had a virus and could lose all my contacts, is this true or a scam?
-
How to remove pages on a mac book models
How to remove templates, I did on my mac through the pages book? the delete button does not work?
-
Satellite L350 - how to use double-click with touchpad?
Hi allI have a Satellite L350-156 and may not know how to get the work of the great plateau, without having to use the buttons, double-clickThanks for your helpM
-
OfficeJet 7612: direct wifi and OfficeJet 7612
I tried to connect my Samsung Galaxy S5 to my new Officejet 7612 via wifi direct, but have had no success. Everything I read seems to verify that this Protocol is available for this printer for wireless printing. Even in charge HP seems impasse. A
-
Router Linksys EA6900 does not
My Linksys EA6900 router does not allow me to connect on any device. I tried to reset and restore but the router will not reset. It is the first version of the material.