Date1 - date2 result in mn


Hi guys,.

I have two date fields, date_field1 and date_field2, both store the date and time.  How do I write a query which subtract date_field1 from date_field2 and give me the results in minutes?  Is this possible?

Thank you.

Hello

If date_field1 and date_field2 are DATEs, then

date_field2 - date_field1

is the number of days between them.  (It will be a negative number if date_field2 is earlier than date_field1.)

To get the difference in minutes rather than days, multiply by the number of minutes in a day: 24 * 60 = 1440

(date_field2 - date_field1) * 24 * 60

Tags: Database

Similar Questions

  • Apply zeros

    Oracle 10 g

    Hi gurus

    I appreciate if someone helps me and offers me a better option for this task...

    I wrote the following code in which I have to format it using zeros, I wrote the following query for the purpose but I wonder if some queries short to perform the same task, please see my code below...

    AS WITH a reference

    (

    SELECT 1 double num_format

    UNION ALL

    10. SELECT FROM dual

    UNION ALL

    100 SELECT FROM dual

    UNION ALL

    SELECT FROM dual 1000

    )

    SELECT num_format, LENGTH WHEN CARTER (num_format) = 1 THEN ' 000'. num_format

    WHEN LENGTH (num_format) = 2 THEN '00'. num_format

    WHEN LENGTH (num_format) = 3 THEN "0". num_format

    WHEN LENGTH (num_format) = 4 THEN to_char (num_format)

    END MODI_FORMAT

    REFERENCE;

    Result

    NUM_FORMAT, MODI_FORMAT

    1 0001

    10 0010

    100 0100

    1000 1000

    Concerning

    Line

    Hello

    Muzz says:

    Hi Frank

    Thank you for my help as usual, in fact in a real world scenario, there are 2 values to date columns, and I need calculate age based on these date columns (date1-date2) and after getting the subtraction then the need to format and display it on the Report Builder in a column, my question is if I can even apply TO_CHAR (num_format, "FM0000") in case of declaration or its OK just add only the to_chat that I've done before. Please advise...

    If you are using a report generator, and then, when you need a column that is displayed in a particular format, use the formatting of this Report Builder features to display the column as you wish.

    If you do it in SQL, and if num_format is a NUMBER, then

    To_char (num_format, "FM0000")

    Returns a representation in the form of 4 digits of this NUMBER, with 0.  It's okay that num_format represents: it could be a number of days, or it could be a price, or an identification number or anything else. (If num_format is less than 0, it actually will return a string of 5 characters, starting with a sign, such as "-0001". ")

    To_char, as I use it, is a substitute for the CASE expression, you had in your original message.  You should be able to do this job without a CASE expression.

  • SQL logic or loops to find this

    Hello

    (Frank: modified requirements of else query I posted yesterday why you gave the right answer)

    Here are the SQL statements...

    Insert into X (MEDICAL_RECORD_NUMBER,VAL,RESULT_DATE) values ('1076789',1.6,to_date('08-08-2008 12:40:00','DD-MM-YYYY HH24:MI:SS'));
    Insert into X (MEDICAL_RECORD_NUMBER,VAL,RESULT_DATE) values ('1076789',1.5,to_date('08-08-2008 15:44:00','DD-MM-YYYY HH24:MI:SS'));
    Insert into X (MEDICAL_RECORD_NUMBER,VAL,RESULT_DATE) values ('1076789',1.4,to_date('09-08-2008 10:58:00','DD-MM-YYYY HH24:MI:SS'));
    Insert into X (MEDICAL_RECORD_NUMBER,VAL,RESULT_DATE) values ('1076789',1.8,to_date('10-08-2008 07:19:00','DD-MM-YYYY HH24:MI:SS'));
    Insert into X (MEDICAL_RECORD_NUMBER,VAL,RESULT_DATE) values ('1076789',1.4,to_date('11-08-2008 06:55:00','DD-MM-YYYY HH24:MI:SS'));
    Insert into X (MEDICAL_RECORD_NUMBER,VAL,RESULT_DATE) values ('1076789',1.2,to_date('12-08-2008 08:12:00','DD-MM-YYYY HH24:MI:SS'));
    Insert into X (MEDICAL_RECORD_NUMBER,VAL,RESULT_DATE) values ('1076789',1.4,to_date('15-08-2008 18:11:00','DD-MM-YYYY HH24:MI:SS'));
    Insert into X (MEDICAL_RECORD_NUMBER,VAL,RESULT_DATE) values ('1076789',1.2,to_date('31-05-2009 13:25:00','DD-MM-YYYY HH24:MI:SS'));
    Insert into X (MEDICAL_RECORD_NUMBER,VAL,RESULT_DATE) values ('1076789',1.4,to_date('01-06-2009 08:27:00','DD-MM-YYYY HH24:MI:SS'));
    Insert into X (MEDICAL_RECORD_NUMBER,VAL,RESULT_DATE) values ('1076789',1.5,to_date('02-06-2009 07:55:00','DD-MM-YYYY HH24:MI:SS'));
    Insert into X (MEDICAL_RECORD_NUMBER,VAL,RESULT_DATE) values ('1076789',1.7,to_date('11-02-2010 17:48:00','DD-MM-YYYY HH24:MI:SS'));
    Insert into X (MEDICAL_RECORD_NUMBER,VAL,RESULT_DATE) values ('1076789',1.5,to_date('23-05-2010 00:20:00','DD-MM-YYYY HH24:MI:SS'));
    Insert into X (MEDICAL_RECORD_NUMBER,VAL,RESULT_DATE) values ('1076789',1.3,to_date('08-06-2010 12:59:00','DD-MM-YYYY HH24:MI:SS'));
    Insert into X (MEDICAL_RECORD_NUMBER,VAL,RESULT_DATE) values ('1076789',0.7,to_date('10-08-2010 19:23:00','DD-MM-YYYY HH24:MI:SS'));
    Insert into X (MEDICAL_RECORD_NUMBER,VAL,RESULT_DATE) values ('1076789',1.4,to_date('04-10-2010 14:16:00','DD-MM-YYYY HH24:MI:SS'));
    Insert into X (MEDICAL_RECORD_NUMBER,VAL,RESULT_DATE) values ('1076789',1.7,to_date('09-02-2011 22:53:00','DD-MM-YYYY HH24:MI:SS'));
    Insert into X (MEDICAL_RECORD_NUMBER,VAL,RESULT_DATE) values ('1076789',1.8,to_date('29-09-2011 19:37:00','DD-MM-YYYY HH24:MI:SS'));
    
    
    

    Output:

    MNR DATE1 DATE 2

    1076789 08/08/2008 15:44 08/15/2008 18:11

    1076789 31/05/2009 13:25

    Process.

    (1) I need to go through all the records in ascending order.

    (2) find the first record where the difference between the values is > = difference of 0.3 and the date is < = 48 hours

    (3) in the above: 08/08/2008 15:44 has an increase of 0.3 compared to the record of 4.

    (4) so keep the date from point 3.

    (5) now must find the peak value within 14 days from 08/08/2008 15:44

    (6) as soon as we have the date starting from which we have the peak value, (which is 10-08-2008 07:19 for value 1.8)... . I need to move through the records following until I find 3 consecutive records that can be found on * DIFFERENT * days to have all 3 records

    a drop of > = 0.3 between 1.8 and get the 3rd date

    (similar to the thread from yesterday: user7431648 )

    If there are 2 folders that are located on the same day, you must consider the 1st date of registration (minimum) that meets the criterion of 0.3.
    Ex: here, in the scenario above, after we had a peak at 1.8 on 08/10/2008-07:19, we have 3 files consecutively

    2008-11-08 06:55

    2008-12-08 08:12

    2008-08-15 18:11

    for which the difference compared to the peak is > = 0.3.

    Then choose the 3rd date or 2 Date in the output... 2008-08-15 18:11

    (7) now repeat the whole process of items 1-6 after 15/08/2008 18:11 (below)

    (8) so that, the next is 31/05/2009 13:25

    (9) the peak within 14 days from 31/05/2009 13:25 is on 2009-02-06 07:55 for which there is an increase of 0.3.

    (10) after 2009-02-06 07:55 there is no drop of > = 0.3 to 3 consecutive records.

    (11) so there is no Date 2 in the output for it.

    Let me know if any part is not clear.

    Thank you

    REDA

    1076789

    Hello

    I found my mistake.  In the subquery got_dates_1_2 at the join condition for the table l, there is a scalar subquery that is corellated to e table.  It must be put into correlation by result_date and medical_record_number, but I left out the medical_record_number above.  I added 1 line (line 33, marked "* NEW * below"), and now it's the production of correct results.

    WITH got_day_vals AS

    (

    SELECT TRUNC (result_date) AS trunc_result_date

    MIN (result_date) DUNGEON (DENSE_RANK FIRST ORDER BY val)

    AS min_result_date

    MAX (MIN (val)))

    PARTITION BY medical_record_number

    ORDER BY TRUNC (result_date)

    LINES BETWEEN 2 PRIOR

    AND CURRENT ROW

    ) AS high_val_3_day

    medical_record_number

    X

    GROUP OF TRUNC (result_date)

    medical_record_number

    )

    got_dates_1_2 AS

    (

    SELECT e.medical_record_number

    e.result_date AS date1

    l.min_result_date AS date2

    ROW_NUMBER () TO)

    PARTITION BY e.medical_record_number

    ORDER BY e.result_date

    l.min_result_date

    ) AS r_num

    X e

    JOIN x p WE p.val =)

    SELECT MAX (val)

    X

    WHERE the result_date BETWEEN e.result_date

    AND e.result_date + 14

    AND medical_record_number = e.medical_record_number-* NEW *.

    )

    AND p.result_date BETWEEN e.result_date

    AND e.result_date + 14

    AND p.medical_record_number = e.medical_record_number

    LEFT JOIN got_day_vals l I l.high_val_3_day<= p.val="" -="">

    AND l.min_result_date > p.result_date

    AND l.high_val_3_day<= greatest="" (="" p.val="" -="">

    , p.val / 2

    )

    AND l.medical_record_number = e.medical_record_number

    WHEN THERE IS)

    SELECT 1

    X

    WHERE (val > = e.val +.3)

    AND result_date BETWEEN e.result_date

    AND e.result_date + 2

    AND medical_record_number = e.medical_record_number

    )

    OR (val > = e.val * 1.5)

    AND result_date BETWEEN e.result_date

    AND e.result_date + 7

    AND medical_record_number = e.medical_record_number

    )

    )

    )

    got_next_r_num AS

    (

    SELECT d.

    ,       (

    SELECT MIN (r_num)

    OF got_dates_1_2

    WHERE medical_record_number = d.medical_record_number

    AND date1 > = d.date2

    ) AS next_r_num

    OF got_dates_1_2 d

    )

    SELECT medical_record_number, date1, date2

    OF got_next_r_num

    START WITH r_num = 1

    CONNECT BY medical_record_number = PRIOR medical_record_number

    AND r_num = PRIOR next_r_num

    ORDER BY medical_record_number

    date1

    ;

  • Select with case statement and a formula of the IIR

    Hi, I was looking to get help regarding a statement writing box with a statement select statement all. I tried to reproduce a formula IIf access well that just wanted to check that the query I wrote is correct, any advice would be appreciated.

    [code]

    Select *.

    Of

    (

    Select name, month, duration, volume, time_spent, date1, date2,.

    -case when 'date' > = 'date1' then '1' other '0' end as departure,.

    -case when 'date' < = "date2" then '1' other '0' as end ending

    Of

    (

    Select *.

    of call_1 cd

    inner join call_2 ON cd.name = cl.queue cl

    )

    )

    ;

    [/ code]

    I want to know is where I have my ' select name, etc, I would change that to select * to make it easier instead of typing all the field_names outside, but I don't know how to do and also what follows is 2 IIF formulas from an access database for the start of the final case statements so I just wanted check I wrote it correctly.

    [code]

    departure: IIf ([date] > = [date1], 1, 0)

    [/ code]

    [code]

    ending: IIf ([date] < = [date2], 1, 0)

    [/ code]

    Any advice would be appreciated.

    Hello

    Whenever you have any questions, post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and the results desired from these data.
    Explain, using specific examples, how you get these results from these data.

    If the output depends on what anyone outside the application itself (for example, when it is run) and then include a few different examples and the results you want of each given the same sample data. For example, "if I run on November 19, 2013, while the results should be... because... but if I run between November 21 and November 27, then the results should be... because...". »
    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: https://forums.oracle.com/message/9362002

    318f20b8-a3d0-4FB4-bb0f-73785250b7d4 wrote:

    Hi, I was looking to get help regarding a statement writing box with a statement select statement all. I tried to reproduce a formula IIf access well that just wanted to check that the query I wrote is correct, any advice would be appreciated.

    [code]

    Select *.

    Of

    (

    Select name, month, duration, volume, time_spent, date1, date2,.

    -case when 'date' > = 'date1' then '1' other '0' end as departure,.

    -case when "date."<= 'date2'="" then="" '1'="" else="" '0'="" end="" as="">

    Of

    (

    Select *.

    of call_1 cd

    inner join call_2 ON cd.name = cl.queue cl

    )

    )

    ;

    [/ code]

    I want to know is where I have my ' select name, etc, I would change that to select * to make it easier instead of typing all the field_names outside, but I don't know how to do and also what follows is 2 IIF formulas from an access database for the start of the final case statements so I just wanted check I wrote it correctly.

    [code]

    departure: IIf([date]>=[date1],1,0)

    [/ code]

    [code]

    ending: IIf ([date]<>

    [/ code]

    Any advice would be appreciated.

    DATE is not a function of Oracle; in fact, it's a terrible name for a column or function, because it blends with the DATE data type.

    In Oracle, the function SYSDATE returns the date and time, according to the clock on the database server.  So, SYSDATE can return a value as November 19, 2013 06:33:15.   If you want to midnight the same day (i.e., November 19, 2013 00:00:00) and then use TRUNC (SYSDATE).

    String literals (for example the string which consists 5 characters d, a, t, e, and 1) go inside the single quotes. Numbers and the names of columns only.

    If you want to include all the columns, more some calculated values, in a SELECT clause, then you must use a name table or alias before the *.  (See select_2 below.  To do this, assign the alias j to display online.)

    Maybe you wanted to say something like:

    Select *-it's select_1

    de)

    Select j. *-it's select_2

    , case when SYSDATE > = date1 then 1 or 0 end as departure

    , case when SYSDATE<= date2="" then="" 1="" else="" 0="" end="" as="">

    de)

    Select *-it's select_3

    of call_1 cd

    inner join call_2 ON cd.name = cl.queue cl

    ) j

    )

    ;

    As mentioned in a previous answer, you should be careful about the use of "SELECT *" in production code.

    In select_3, it would be better if you explicitly listed the columns you need.  It can improve efficiency and maintenance.  In this request, queue and the name will be always the same, so you probably don't want to include both of them in the result set, in any case.

    In select_1 and select_2, it is acceptable to use "SELECT *", assuming that select_3 is fixed.

    Moreover, there is no point in using subqueries here.  You can get the same results simply in a single query, without any subqueries.

  • date formats

    Hi, I have a varchar column in a table of date values have been stored.
    My problem is like this column, that the date values are stored in different formats.

    I need releases, formats and for updating in the format mm-dd-yyyy. return to the table.


    is it possible to do

    ex:
    the column is varchar2 samp (99);

    I have I have date values in

    several formats such as

    26.05.2011 18:43:38
    31/05/2011 12:05:09
    17/06/2011 18:06:08
    22.06.2011 15:26:08
    14/06/2011 16:19
    16/06/2011-17:43:35
    17 January 12

    need to identify formats and update properly in the format mm-dd-yyyy hh

    pls season how to do

    you've probably already seen this thought, but if you do not know the format it was recorded like how do you know if 02/01/2012 is first jan or February second.

    How do you know if 06:00 06:00 or 18:00 if am or pm is not given?

    You have to make certain assumptions in the transformation. you have some coding to do.
    Either create a plsql package to browse the data and captures all exceptions and turn them into loop points and dashes to / then look for hours and hours and transform.

    or do all in sql
    Create a new table with several columns of transformations. Let's say 5.

    create table trans_col (pk_id, varchar2 date1, date2 varchar2, varchar2, varchar2, date date.5 date4 date3)

    insert into trans_col (pk_id, date1) values (select pk_id, bad_Date_col from master_table)

    then cross the iterations change the dates, change the points and dashes to /.
    Update trans_Col set date2 = replace (date1, '.', ' / ')

    replace the months with numbers.
    Update trans_Col set date3 = replace (date1, 'JAN', '01')... etc.

    assumes that the am or pm time and transform. keep up to date the following columns and display results. You should really do with a plsql however procedure.

  • seconddate in a table

    Hi experts,
    I want to get firstdate and seconddate for each line

    able to get firstdate BY the MERGE HELP but could not get the iam IAM seconddate
    CREATE TABLE test
    (
       id      NUMBER,
       date1   DATE,
       date2   DATE,
       date3   DATE,
       date4   DATE,
       date5   DATE
    );
    
    
    INSERT INTO TEST (ID,
                      DATE1,
                      DATE3,
                      DATE4)
         VALUES (1,
                 TO_DATE ('01/25/2012 11:26:37', 'MM/DD/YYYY HH24:MI:SS'),
                 TO_DATE ('01/27/2012 11:26:37', 'MM/DD/YYYY HH24:MI:SS'),
                 TO_DATE ('01/28/2012 11:26:37', 'MM/DD/YYYY HH24:MI:SS'));
    
    INSERT INTO TEST (ID, DATE3, DATE5)
         VALUES (
                   2,
                   TO_DATE ('01/28/2012 11:26:37', 'MM/DD/YYYY HH24:MI:SS'),
                   TO_DATE ('01/29/2012 11:26:37', 'MM/DD/YYYY HH24:MI:SS'));
    
    INSERT INTO TEST (ID, DATE3)
         VALUES (3, TO_DATE ('01/29/2012 11:26:37', 'MM/DD/YYYY HH24:MI:SS'));
    
    INSERT INTO TEST (ID,
                      DATE1,
                      DATE2,
                      DATE3,
                      DATE4,
                      DATE5)
         VALUES (4,
                 TO_DATE ('01/26/2012 11:26:37', 'MM/DD/YYYY HH24:MI:SS'),
                 TO_DATE ('01/29/2012 11:26:37', 'MM/DD/YYYY HH24:MI:SS'),
                 TO_DATE ('01/30/2012 11:26:37', 'MM/DD/YYYY HH24:MI:SS'),
                 TO_DATE ('01/31/2012 11:26:37', 'MM/DD/YYYY HH24:MI:SS'),
                 TO_DATE ('02/02/2012 11:26:37', 'MM/DD/YYYY HH24:MI:SS'));
    
    INSERT INTO TEST (ID, DATE1)
         VALUES (5, TO_DATE ('01/27/2012 11:26:37', 'MM/DD/YYYY HH24:MI:SS'));
    
    INSERT INTO TEST (ID, DATE1, DATE5)
         VALUES (
                   6,
                   TO_DATE ('01/30/2012 11:26:37', 'MM/DD/YYYY HH24:MI:SS'),
                   TO_DATE ('02/03/2012 11:26:37', 'MM/DD/YYYY HH24:MI:SS'));
    
    COMMIT;
    
    SELECT * FROM TEST;
    
    My result should look LIKE:
    
    
    
    FOR id=1
    
     firstdate =1/25/2012 11:26:37 AM
    
     seconddate=1/27/2012 11:26:37 AM
    
     FOR id=2
    
      firstdate=1/28/2012 11:26:37 AM
      seconddate=1/29/2012 11:26:37 AM
    
     FOR id=3
    
      firstdate=1/29/2012 11:26:37 AM
      seconddate=NULL
    
    
       FOR id=4
    
      firstdate=1/26/2012 11:26:37 AM
      seconddate=1/29/2012 11:26:37 AM
    
       FOR id=5
    
      firstdate=1/27/2012 11:26:37 AM
      seconddate=NULL
    
    
       FOR id=6
    
      firstdate=1/30/2012 11:26:37 AM
      seconddate=2/3/2012 11:26:37 AM
    
    
    i tried this :
    
    select id,coalesce(date1,date2,date3,date4,date5) firstdate from test;
    
      
    Thanks in advance

    Hello

    It is a really bad table design. The fact that you might one of the 5 dates indicates that they are really that different instances of the same thing, and they belong to a single column on 5 different lines, not 5 different columns on a single line.

    One thing you can do is unpivot 5 columns on 5 lines, because they must have been stored in the first place. Then, you can use the ROW_NUMBER analytic function to get the Nth one.

    If you don't want to do it, here is another approach:

    SELECT     id
    ,     CASE
             WHEN  date1 IS NOT NULL  THEN COALESCE (date2, date3, date4, date5)
             WHEN  date2 IS NOT NULL  THEN COALESCE (         date3, date4, date5)
             WHEN  date3 IS NOT NULL  THEN COALESCE (               date4, date5)
                                          ELSE                           date5
         END     AS second_date
    FROM    test;
    
  • Get data from YEAR_WEEK for the next WEEKS 20

    Hi all

    I have a select query and when I run this query, that query is display data for all YEAR_WEEK of PROD_BACKLOG table. The YEAR_WEEK column in the PROD_BACKLOG table data in this format 2030-WK41.

    My select query is the following
    SELECT 
                  DC_UTIL.GEN_YEAR_WEEK(MSD) YEAR_WEEK,
                  ITEM_NUMBER,
                  BACKLOG_QUANTITY,
                  MSD
                  to_char(MSD, 'IW')
                  FROM prod_BACKLOG
                  where to_char(MSD, 'IW')>to_char(sysdate, 'IW');
    I would like to add a clause in this query should it search only for data for the next few weeks more 20.

    Thanks in adavnce

    Concerning

    Hello

    I think that you have given for more than a year, which is why queries of does not return the same number of lines:
    -For your TO_CHAR, you keep only the week number and don't care of the week, which means that the 29th week of 2011 is the same as the 29th week of 2012
    -With the TRUNK, you compare the first days of the week, which include information on the year

    Here is an example: you'll see Date1 is the same for 2 dates, but Date2 shows different results and take care of the year:

    with t as (
    select to_date ('20/07/2011','DD/MM/YY') MSD from dual union all
    select to_date ('20/07/2012','DD/MM/YY') MSD  from dual
    ) select to_char(MSD, 'IW') date1, trunc (MSD, 'IW') date2 from t;
    
    DATE1      DATE2
    ---------- ---------
    29         18-JUL-11
    29         16-JUL-12
    

    You must choose the trunc.

    Using< or=""><= in="" this="" part="" of="" the="" where="">

    and trunc(MSD, 'IW')<=trunc(sysdate+140, 'IW');
    

    won't change of data greater than the week or not, but will include or not data for the 20th week.

    Hope that is more clear.

    Kind regards
    Sylvie

  • How to get the difference in dates in days

    Hi friends,

    How to get the date difference between two dates exactly

    date2-date1 days exactly... shouyld rounded to the nearest value of...

    and one entire display i mean positive integer
    Select round ((sysdate) - to_date (date_start)), date_start days of per_periods_of_service

    This gives negative also result

    Hello

    776317 wrote:
    Hi friends,

    How to get the date difference between two dates exactly

    date2-date1 days exactly... shouyld rounded to the nearest value of...

    Date1 - date2 is the exact number of days is after date2 date1. (It is as accurate as possible, given that the DATEs do not have fractions of a second).

    and one entire display i mean positive integer
    Select round ((sysdate) - to_date (date_start)), date_start days of per_periods_of_service

    You want to probably get the exact number of days first, then ROUND this number:

    SELECT  ROUND (SYSDATE - TO_DATE (date_start, ...))   AS days
    FROM    per_periods_of_service; 
    

    Always pass arguments at least 2 to TO_DATE:
    (1) the string to be converted, and
    (2) a saying string how (1) is formatted

    This gives negative also result

    Right; If date1 is before date2 then date1 - date2 returns a negative number.
    If you want to never get a negative value, use ABS (date2 - date1). If it returns 4, then you know that one of the DATEs was 4 days before the other, but you won't know who was earlier.

    I hope that answers your question.
    If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) and also publish outcomes from these data.
    Explain, using specific examples, how you get these results from these data.
    Always tell what version of Oracle you are using.

  • Subtracting days from a Date

    Am using Acrobat 9 Pro for Windows.  I have a form where I want to subtract days from Date1 and Date2 results.  The Date1 and Date 2 text boxes are not formatted.  I tried reading the articles of 'date' and experimental with formulas but I'm afraid that I am still illiterate Acrobat.  Any ideas?  Thank you.

    It would be better if you set the Date1 field to be formatted as a date. In this way, Acrobat uses a built-in routine to validate automatically the entry represents a valid date. You can then use a calculation script custom of the field Date2 that looks like:

    // Custom Calculate script for text field
    (function () {
    
        // Get Date1 field value
        var v = getField("Date1").value;
    
        // If field is empty, blank this field
        if (v === "") {
            event.value = v;
            return;
        }
    
        // Convert the date string to a date object
        var d = util.scand("mm/dd/yyyy", v);
    
        // Subtract 5 days
        d.setDate(d.getDate() - 5);
    
        // Set this field's value
        event.value = util.printd("mm/dd/yyyy", d);
    
    })();
    

    Change the format of date (mm/dd/yyyy) in the code above to match what you want to use.

  • Data (date Math) Member text 1 less the text of 2 members

    Help!  I'm building something as an "age of the auditor.

    > > I'm looking to subtract dates

    I have a text called "DateToday" -is today's date

    and a member of text called "DateYouTyped" -indexed by the user (first YEAR then MONTH, DAY) using the format YYYYMMDD

    How 'pull' the text of members and use as part of the formula?


    And that the formula would look like

    I used Director help and found

    myBirthday = date (19650712)

    YourBirthday = date (19450529)

    You would do something like

    Date1 = .text ("DateToday" member)

    day 2 = (member("DateYouTyped).text

    and then

    set date1 - date2?  I want the result to go in a text member lets call it 'finalanswer '.

    You got an answer that, admittedly, I didn't spend too long picking apart - mainly because it seemed too complicated.

    I approach what you describe by first making sure there are enough numbers entered to create a valid date - this includes leading zeros in the case of the day and the month. Either that, or provision of input fields separate year, month and day that can be validated individually. However, go with your 8-digit imagined the 'trick' entry is to enter the first 4 characters of the year, the month and the last 2 as day 2 and compel them to strings to integers. Something like:

    sDateToday = member("DateToday").text
    tYear = value(sDateToday.char[1..4])
    tMonth = value(sDateToday.char[5..6])
    tDay = value(sDateToday.char[7..8])
    dToday = date(tYear, tMonth, tDay)
    
    sDateEntered = member("DateYouTyped").text
    tYear = value(sDateEntered.char[1..4])
    tMonth = value(sDateEntered.char[5..6])
    tDay = value(sDateEntered.char[7..8])
    dEntered = date(tYear, tMonth, tDay)
    
    -- this gives the number of days between the 2 dates
    -- it's not clear how you want the result formatted, so ...
    nDifference = dToday - dEntered
    member("finalanswer").text = "There are" && string(nDifference) && "days between the two dates entered"
    
  • DateDiff

    Hello

    If I only ouput date1 and date2, I got the results: date1 is 20/04/2006 and date2 is 5/03/2006.
    I also ouput #DateDiff('d','4/20/2006','5/03/2006 ') # and I got the result for 13 different days
    BUT when I exit #DateDiff('d','date1','date2') #, I got the following error:
    =====
    Parameter for the function DATEDIFF validation error.
    The value of parameter 2, which is currently "date1", must be a value of class java.util.Date.
    =====

    Here is my code, please tell me what I have wrong here?

    < cfoutput query = "getnews" >
    < cfset date = now() >
    < cfset date1 = "#dateformat(upload_date,'m/dd/yyyy') #" >
    < cfset date2 = "#dateformat(date,'m/dd/yyyy') #" >
    #date1 #-#date2 # -.
    #DateDiff('d','date1','date2') #.
    <!-#DateDiff('d','4/20/2006','5/03/2006 ') #-->
    < / cfoutput >

    Thank you

    Hello

    If I only ouput date1 and date2, I got the results: date1 is 20/04/2006 and date2 is 5/03/2006.
    I also ouput #DateDiff('d','4/20/2006','5/03/2006 ') # and I got the result for 13 different days
    BUT when I exit #DateDiff('d','date1','date2') #, I got the following error:
    =====
    Parameter for the function DATEDIFF validation error.
    The value of parameter 2, which is currently "date1", must be a value of class java.util.Date.
    =====

    Here is my code, please tell me what I have wrong here?





    #date1 #-#date2 # -.
    #DateDiff('d','date1','date2') #.

    Thank you

  • Look for the date range

    Table data and the sample are as mentioned below. I have 2 dates ' 4 / 14/2010 (Date1)' and ' 4 / 25/2010 ' (Date2). Need to retrieve all the rows present in this range.

    that Date1 and Date2 must be greater than or equal to the start date and less than or equal to the end date.
     CREATE TABLE test_1
    (
      ID     VARCHAR2(4000 BYTE),
      DESCRIPTION  VARCHAR2(500 BYTE),
      START_DT     DATE,
      END_DT       DATE
    ) 
    Insert into TEST_1
       (ID, DESCRIPTION, START_DT, END_DT)
     Values
       ('1', 'Apple', TO_DATE('03/01/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('03/31/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into TEST_1
       (ID, DESCRIPTION, START_DT, END_DT)
     Values
       ('2', 'Ball', TO_DATE('03/04/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('03/17/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into TEST_1
       (ID, DESCRIPTION, START_DT, END_DT)
     Values
       ('3', 'Cat', TO_DATE('04/13/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('04/30/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into TEST_1
       (ID, DESCRIPTION, START_DT, END_DT)
     Values
       ('4', 'Dog', TO_DATE('04/21/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('04/28/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into TEST_1
       (ID, DESCRIPTION, START_DT, END_DT)
     Values
       ('5', 'Elephant', TO_DATE('04/22/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('04/27/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into TEST_1
       (ID, DESCRIPTION, START_DT, END_DT)
     Values
       ('6', 'Fox', TO_DATE('04/14/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('05/18/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));

    Hello

    Thanks for posting the sample data in a useful form. It is very useful.
    You should also post the results desired from these data. That can be useful too, especially when the description is vague, because this description is:

    user13024762 wrote:
    Table data and the sample are as mentioned below. I have 2 dates ' 4 / 14/2010 (Date1)' and ' 4 / 25/2010 ' (Date2). Need to retrieve all the rows present in this range.

    that Date1 and Date2 must be greater than or equal to the start date and less than or equal to the end date.

    To find all lines where the two
    Date1 is greater than or equal to the start date and less than or equal to the maturity, and
    Date2 is greater than or equal to the start date and less than or equal to the end date

    WITH     params     AS
    (
         SELECT     TO_DATE ( '04/14/2010 00:00:00'
                   , 'MM/DD/YYYY HH24:MI:SS'
                   )     AS Date1
         ,     To_DATE ( '04/25/2010 00:00:00'
                   , 'MM/DD/YYYY HH24:MI:SS'
                   )     AS Date2
         FROM     dual
    )
    SELECT     *
    FROM     test_1     t
    JOIN     params     p     ON     p.Date1     BETWEEN     t.start_dt
                             AND     t.end_dt
                   AND     p.Date2     BETWEEN     t.start_dt
                             AND     t.end_dt
    ;
    

    Output:

    ID DESCRIPTIO START_DT            END_DT              DATE1               DATE2
    -- ---------- ------------------- ------------------- ------------------- -------------------
    3  Cat        04/13/2010 00:00:00 04/30/2010 00:00:00 04/14/2010 00:00:00 04/25/2010 00:00:00
    6  Fox        04/14/2010 00:00:00 05/18/2010 00:00:00 04/14/2010 00:00:00 04/25/2010 00:00:00
    
  • Using HTTPService to fill Combobox from DB SQL

    I'm having a little problem with the filling of a combobox after I call a httpservice. Showing data, however, it's all appear on a single line over several items to combobox. For example, I get a single line in the drop-down menu that looks like this:

    DATE1, DATE2, DATE3

    instead of get:

    DATE1
    DATE2
    DATE3

    I found this article, but it does not really my problem and I already seem to wear all recommended in this article ( http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=60 & catid = 585 & threadid = 1220768 & highlight_key = y & keyword1 = combobox).

    Part of my PHP script:
    -----------------------------------------------
    $return = '< horodateurs > ';
    While ($Row = mysql_fetch_array ($result))
    {
    $qrtrdisp is $row ["quarter"];.
    $return. = "< date >." $qrtrdisp. "< / date > ';
    }
    $return. = ' < / timestamps > ';
    Print ($Return);
    -----------------------------------------------

    Part of my MXML file:
    -----------------------------------------------
    "" < mx:Application xmlns:mx = ' http://www.adobe.com/2006/mxml ' layout = "absolute" creationComplete = "getDates.send ()" >

    <!-set call to enter the dates for the shape->
    < mx:HTTPService id = "getDates" url = "https://url/file.php" useProxy = "false" method = "GET" showBusyCursor = "true" >
    < / mx:HTTPService >

    < mx:ComboBox id = "dates" x = "201" y = "6" dataProvider = "{getDates.lastResult.timestamps}" labelField = 'date' > < / mx:ComboBox > ""
    -----------------------------------------------

    Any help would be greatly appreciated.

    Thank you
    Chris

    You may need to structure xml youre differently. You set the dataprovider for the timestamps down, try each date in its own node parent and dot up to getDates.LastResult.timestamps of packaging. (the new node)

  • Combine the ORDER BY sorting columns?

    Hello-

    I wonder if this is possible:

    I would like to combine two columns of Dates (from separate tables) so that the SELECT result can be sorted (ORDER BY) based on the order of these TWO dates, not just one or the other.

    Wherever a date exists in a column, the other column contains a null entry. For example:

    ID-date1 - date2.
    0 - draw - 12/09/09
    1 08/04/09 - null.
    2 - null - 06/12/09
    3 08/12/09 - null.

    (forgive the formatting)

    Essentially, I want to leave null values and possess a solid column of dates to sort a SELECT with query. Is this possible? If so, how?

    The two date columns have type DATE - they are not strings. They also store sometimes, but I don't understand as in the illustration above for simplicity. The columns are two separate tables, but who are joined with a join internal based on an ID value that connects the two (not sure if it's too big).

    I am also open to any other ideas about how I could sort the results based on the two sets of dates; Looks like some kind of cartel would be the simplest or most logical (even if I'm wrong, because I can't find a way to do it).

    Thank you!

    Salvation;

    select tableA.id, nvl(tableA.date1, tableB.date2) as combined_dt
    from tableA, tableB
    where tableA.id=tableB.id
    order by 2
    

    Kind regards...

  • NULL values in service management LESS

    Hello

    I have the query unless you return through two date fields date... NULL values should be ignored in the calculation. I used the service LESS with NVL but not able to resolve the issue until I used the function REPLACE top of it to show the value NULL if the query returns date of NVL. Please find the tables and queries that I used...
    CREATE TABLE TEST_LEAST
    (RECORD NUMBER,
    DATE1 DATE,
    DATE2 DATE,
    DATE3 DATE);
    INSERT INTO TEST_LEAST VALUES (1, '1 AUG 2009', '23 JUN 2009', '4 APR 2009');
    INSERT INTO TEST_LEAST VALUES (2, '20 JAN 2009', '16 FEB 2009', '7 MAY 2009');
    INSERT INTO TEST_LEAST VALUES (3, NULL, '31 MAR 2009', '19 JUL 2009');
    INSERT INTO TEST_LEAST VALUES (4, NULL, NULL, NULL);
    COMMIT;
    To return date less date1 and date2, date3, I used the function LESS, but the result was not as expected with the following query:
    SELECT RECORD, LEAST(DATE1, DATE2, DATE3) FROM TEST_LEAST;
    Statement 3 should show a date of March 31, 2009.

    I changed the query to use NVL to handle NULL values...
    SELECT CASENBR, LEAST(NVL(DATE1, TO_DATE('31 DEC 9999')), NVL(DATE2, TO_DATE('31 DEC 9999')), NVL(DATE3, TO_DATE('31 DEC 9999'))) FROM TEST_LEAST;
    .. but now, the result shows that record 4 is December 31, 2009, instead of NULL.
    and finally, I replaced the date 31 DEC 2009' with null with this query...
    SELECT CASENBR, REPLACE(LEAST(NVL(DATE1, TO_DATE('31 DEC 9999')), NVL(DATE2, TO_DATE('31 DEC 9999')), NVL(DATE3, TO_DATE('31 DEC 9999'))), TO_DATE('31 DEC 9999'), NULL) FROM TEST_LEAST;
    I am not convinced with query then thought to ask THE GURUS for help. Please guide me how I can better handle nulls with LESS function.

    Thanks in advance!

    Use COALESCE with the first expression that column:

    SQL> SELECT RECORD, LEAST(COALESCE(DATE1,DATE2,DATE3),COALESCE(DATE2,DATE3,DATE1),COALESCE(DATE3,DATE1,DATE2))FROM TEST_LEAST;
    
        RECORD LEAST(COA
    ---------- ---------
             1 04-APR-09
             2 20-JAN-09
             3 31-MAR-09
             4
    
    SQL> 
    

    SY.

Maybe you are looking for

  • How to uninstall TOSHIBA Bluetooth Stack and all the drivers?

    Hello! I installed TOSHIBA Bluetooth Stack of [here | http://aps2.toshiba-tro.de/bluetooth/?page=download] or, more precisely of the [here | http://aps2.toshiba-tro.de/bluetooth/?page=download-toshiba] (8.00.12 |) Windows 2000 / XP / Vista / Windows

  • Is there a solution for the Airplay audio offset between the speakers?

    I use the Apple TV4 and all control as a speaker using Airplay from my laptop to Windows PC in an adjacent room. I get a very ennuyeux.5 second or 1 second audio delay when the speaker of the laptop and ATV4 speakers are on. I use a high-speed networ

  • Satellite L850/0C9 and resolutions HDMI

    Hi all. Ive recently bought a 9 L850/0c and I can not get the HDMI output to 1360 x 768, which is the native resolution of my panels. Using a vga cable that I can output to 1360 x 768, but not with HDMIAny ideas? Windows 7 Home Premium 64-bit

  • Table column attribute

    Hello I create a table in the CVI 2009 during execution by adding columns with column labels.  Some columns are inserted in digital and some format as a format string. The table is then filled with a spreadsheet Excel using «ExcelRpt_ReadDataToTableC

  • Cannot print multiple pages of works

    9.0 Windows using Windows Vista, I can not print multiple pages of any file Works with the command 'print' in the 'folder '.  I checked the solution center but found no help.  The manufacturer of the computer/printer says it's a problem of applicatio