Last day of the month with the last minute of the day

Hello
I wonder about how to get the last day of the month with the last minute of this day(23:59). We can use the last_day function (DATE) to get the last date, but reminds me of the time of day when the function has been executed. But I want to have the last minute with my last date of the current month.

Please inform.

Thank you

HP

Hello

Ora_bie wrote:
Hello
I wonder about how to get the last day of the month with the last minute of this day(23:59). We can use the last_day function (DATE) to get the last date, but reminds me of the time of day when the function has been executed. But I want to have the last minute with my last date of the current month.

In fact, it returns at the same time as the argument you pass; But whatever it is, is not what you want.

This will return the last day of the month that contains the DATE 23:59 (or 23:59) dt:

SELECT  ADD_MONTHS ( TRUNC (dt, 'MONTH')
             , 1
             ) - (1 / (24 * 60))
FROM    dual
;

TRUNC (dt, 'MONTH') is 00:00 on the first day of the month that contains dt.
ADD_MONTHS (TRUNC (dt, 'MONTH'), 1) is from 00:00 the first day of the month following the one containing dt.
ADD_MONTHS (TRUNC (dt, 'MONTH'), 1)-(1 / (24 * 60)) is a minute earlier.
(Since there are 24 hours, each with 60 minutes, every day, 1 / (24 * 60) days is identical to a minute.)

Another (less clear, in my opinion) way to get the same results is:

TRUNC (LAST_DAY (dt)) + (1439/1440)  -- 1440 minutes = 1 day

Tags: Database

Similar Questions

  • How can I change the duration of an MP3 file I downloaded? For example, I have a song that 1.5 last minute, but I want to only keep the 21 seconds. How can I culture there?

    How can I change the duration of an MP3 file I downloaded? For example, I have a song that 1.5 last minute, but I want to only keep the 21 seconds. How can I culture there?

    Your best bet would be looking for writers to mp3/wave. There are a few very good freeware/shareware sound there. I suggest this so that you can choose what format you want to save your file cropped as.

  • reason for my windows 7 OS crashed & had to be re-installed seven times in nine months with the losse of precious files is the same reason that microsoft has been duffed the international space station?

    am I right to assume that the same reason, my windows 7 OS crashed & had to be re-installed seven times in nine months with the losse of precious files is the same reason that microsoft has been duffed the international space station?

    Hello

    If I understand correctly you install os 7 times, still problem happens, its just a bad sector in plateau, well shot cause want to check your hard drive a d, you need to change your hard drive to solve this problem, if it is in warranty log a ticket

  • Hello, I bought Adobe Creative Suite. I joined by monthly payment (€60,49 / month) with a one year subscription. The problem is that my screen says «your order is processing...» ». I bought it yesterday morning and today I am still waiting to

    Hello, I bought Adobe Creative Suite. I joined by monthly payment (€60,49 / month) with a one year subscription. The problem is that my screen says «your order is processing...» ». I bought it yesterday morning and today I am still waiting to complete my installation. I need to work earlier. How can I proceed? Thank you.

    You can use the subscription on a trial basis pending before buying to clear the system.

    If it is not resolved then contact Adobe support directly.

    To the link below, click on the still need help? option in the blue box below and choose the option to chat or by phone...

    Make sure that you are logged on the Adobe site, having cookies enabled, clearing your cookie cache.  If it fails to connect, try to use another browser.

    Creative cloud support (all creative cloud customer service problems)

    http://helpx.Adobe.com/x-productkb/global/service-CCM.html ( http://adobe.ly/19llvMN )

  • How many photos can I create and edit per month with the $9.99 plan?

    I was wondering if there was no limitation on the number of projects I can do in a month with the $9.99 plan

    Hi crisr27764025,

    There is no limit to the number of photos.

    You can change as many photos/projects using Lightroom and Photoshop you want (with the $9.99 plan)

  • Why if I pay every month with my VISA card I can't use the program? Said THAT THE TRIAL has EXPIRED? and I pay every month!

    Por that TR pago my a my con mi tarjeta VISA no puedo use el programa?  Me as EL PERIODO DE PRUEBA HA CADUCADO?

    Why if I pay every month with my VISA card I can't use the program? Said THAT THE TRIAL has EXPIRED? and I pay every month!

    Telefono del servicio customer service numbers support Adobe tecnica in todo el mundo y

    País/región Attention to the client
    Norteamérica
    EE. UU. There Canada 800-443-8158.
    Europa
    Austria 6950071855 3 option
    BELGICA 027 119 960 3 option
    Dinamarca + 45 38 322 914 option 3
    Irlanda + 353 (0) 1 242 1552 option 3
    Finlandia + 358 (0) 969 379 671 option 3
    Francia 01 71 23 01 96 option 3
    Alemania 6950071855 3 option
    Italia 02 6 968 2817 option 3
    Countries Bajos + 31 (0) 20 201 3331 option 3
    Noruega + 47 23 16 28 81 option 3
    España 900 810339 option 3
    Suecia + 46 (0) 858 536 692 option 3
    Suiza 18009581 3 option
    RU + 44 (0) 207 365 0733 option 3
    Asia/Pacífico
    Australia 1800 614 863
    China 58657700 010
    Hong Kong 30714922
    India 0124 4003810

    000 800 440 1751 Indonesia 001 803 447 361 on 03-5350-0407 Corea 02 563 2555 Malasia 1 300-80-0027 Nueva Zelanda 0 800 485 948 Filipinas 180014410440 Singapur 800-448-1642 Taiwan 0800-666-536 Tailandia 001 800 441 8813 Otro + 632 636 8450 Latinoamerica Argentina 0 800 444 0290 Brasil 0800 8921704 El Caribe 206-675-6100 Central America 206-675-6100 Chile 1230-020-0109
    206-675-6100 Colombia 01 800 5 1 80102
    206-675-6100 Costa Rica 0 800 011 0910
    206-675-6100 Mexico City 001 800 249 1039
    206-675-6100 Sudamérica 206-675-6100 Venezuela 206-675-6100 Africa South Africa + 44 (0) 20 7365 0733
  • Group by month and also to see the month with no record

    Hi - a mental block important this morning, pretty sure it's a simple one types just need of you experts to point me in the right direction...

    Using the data from the example below, I just need to generate a report to show the username, mon-yy, number of transactions. I need to show the 12 months, with a zero if there is no transaction.

    I don't know if it's the right approach, but I use a subquery to generate 12 months, like obvisouly they aren't in transaction data. The fact that I have to_char against the kind of subquery to set the alarm bells ringing, I think that there is a better solution, but as I say, mental block.

    The query at the end was to show the thing of subquery works, but for the life of me I can't think today how to extend this option to include the user ID and give me the desired result (bottom code block).

    Frustrating when it should be relatively simple.

    Thanks in advance to all: o)
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0
    create table trans (pkid number, userid number, transdate date);
    
    insert into trans values (1, 10, sysdate-300);
    insert into trans values (2, 10, sysdate-100);
    insert into trans values (3, 20, sysdate-100);
    insert into trans values (4, 20, sysdate-50);
    insert into trans values (5, 20, sysdate-20);
    commit;
    
    select * from trans;
    
          PKID     USERID TRANSDATE
    ---------- ---------- ---------
             1         10 05-AUG-10
             2         10 21-FEB-11
             3         20 21-FEB-11
             4         20 12-APR-11
             5         20 12-MAY-11
    
    select sub.mon, count(t.transdate) from trans t,
    (select to_char(add_months(sysdate, -level),'MON-YY') as mon
    from dual
    connect by level <=12) sub
    where sub.mon = to_char(transdate(+),'MON-YY')
    group by sub.mon
    order by to_date(sub.mon,'MON-YY')
    /
    
    MON    COUNT(T.TRANSDATE)
    ------ ------------------
    JUN-10                  0
    JUL-10                  0
    AUG-10                  1
    SEP-10                  0
    OCT-10                  0
    NOV-10                  0
    DEC-10                  0
    JAN-11                  0
    FEB-11                  2
    MAR-11                  0
    APR-11                  1
    MAY-11                  1
    
    12 rows selected.
    Desire:
    10  JUN-10  0
    10  JUL-10  0
    10  AUG-10  1
    ...and so on until...
    10  MAY-11  0
    
    20  JUN-10  0
    20  JUL-10  0
    20  AUG-10  0
    ...and so on until...
    20  FEB-11  1
    20  MAR-11  0
    20  APR-11  1
    20  MAY-11  1

    Hello

    This is what a Partitionné Outer Join :

    select        sub.mon
    ,        count (t.transdate)
    from        (
              select      to_char ( add_months (sysdate, -level)
                        , 'MON-YY'
                        ) as mon
              from      dual
              connect by      level      <= 12
           ) sub
    left outer join trans     t     PARTITION BY (t.userid)
                        ON      sub.mon = to_char (transdate,'MON-YY')
    group by  t.userid
    ,       sub.mon
    order by  t.userid
    ,       to_date (sub.mon,'MON-YY')
    ;
    

    A standard outer join ensures that you will get each row of the table of conduct displayed at least once. But you want each line of void poster n times, where n is the number of distinct identifiers in t. "PARTITION BY t.userid" means "treat each distinct value of the user name as a separate table" and the results will all be clauses together.

    There were new partitioned outer joins in Oracle 10. Previously, you had to form a set of distinct values for the user name, then the join cross-who with the distinct void months and finally outer join for the actual data.

  • I bought an annual subscription from month to month with Adobe Creative Cloud. I have the applications installed on my Mac but when I downloaded Adobe Creative cloud on my PC, it's wanting to download me new applications of 2014 and there is no way to dow

    I bought an annual subscription from month to month with Adobe Creative Cloud. I have installed on my Mac apps but when I downloaded Adobe Creative cloud on my PC, it's wanting to download me new applications of 2014 and there is no way to download previous versions for my PC. What should I do? I can not even cancel my subscription because Adobe has hidden this option.

    Previous through Cloud http://helpx.adobe.com/creative-cloud/help/install-apps.html#previous

    Cancel http://helpx.adobe.com/x-productkb/policy-pricing/return-cancel-or-change-order.html

    -or by phone http://helpx.adobe.com/x-productkb/global/phone-support-orders.html

  • Count of the number of months with unpaid for the last six months

    Hello

    I now table to store the daily presence of each employee

    ATTENDANCESHEET

    EMPID

    PAYROLLDATE

    UNPAID

    1

    10/01/2013

    6

    1

    10/02/2013

    2

    1

    11/01/2013

    0

    1

    11/02/2013

    0

    1

    12/01/2013

    0

    1

    12/02/2013

    0

    1

    01/01/2014

    0

    1

    01/02/2014

    0

    1

    02/01/2014

    0

    1

    02/02/2014

    0

    1

    03/01/2014

    45

    1

    03/02/2014

    0

    2

    03/01/2014

    0

    2

    03/02/2014

    0

    I want to get the number of months used unpaid in the past 6 months (excluding the current).

    If the month of payroll, I'm in treatment is 4, 2014, I spend 4 as payrollmonth and 2014 as payroll year

    The application must check the latest 6 month data and number of months for which there is any unpaid value

    In the case above for month 4, 2014, the power required is

    EmpID

    County

    1

    2

    2

    0

    I use oracle 10g

    EXAMPLES OF DATA

    create the table attendancesheet as

    (

    Select 1 as empid, to_date (January 10, 2013 ',' DD/MM/YYYY ') as payrolldate, 6 paid by union double all the

    Select 1 as empid, to_date (10 February 2013 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the

    Select 1 as empid, to_date (January 11, 2013 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the

    Select 1 as empid, to_date (February 11, 2013 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the

    Select 1 as empid, to_date (12 January 2013 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the

    Select 1 as empid, to_date (February 12, 2013 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the

    Select 1 as empid, to_date (1 January 2014 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the

    Select 1 as empid, to_date (February 1, 2014 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the

    Select 1 as empid, to_date (January 2, 2014 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the

    Select 1 as empid, to_date (February 2, 2014 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the

    Select 1 as empid, to_date (3 January 2014 ',' DD/MM/YYYY ') as payrolldate, 45 paid by union double all the

    Select 1 as empid, to_date (3 February 2014 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the

    Select 2 as empid, to_date (3 January 2014 ',' DD/MM/YYYY ') as payrolldate, 0 as default all the double union

    Select 2 as empid, to_date (3 February 2014 ',' DD/MM/YYYY ') as payrolldate, 0 paid double

    );

    Help, please

    Hello

    So, you want to count the distinct months for 6 months before (not included) the given month; is this fair?

    Here's one way:

    VARIABLE month VARCHAR2 (2)

    Year VARIABLE VARCHAR2 (4)

    EXEC: months: = '4';

    EXEC: year: "2014"; =

    WITH got_end_date AS

    (

    SELECT TO_DATE (: month |) '/' || : year

    , ' MM/YYYY ".

    ) AS end_date

    OF the double

    )

    SELECT a.empid

    , COUNT (DISTINCT

    CASE

    WHEN a.unpaid > 0

    THEN TRUNC (a.payrolldate, 'MONTH')

    END

    ), Cnt

    Of attendancesheet one

    JOIN e-got_end_date WE a.payrolldate > = ADD_MONTHS (e.end_date-6)

    AND a.payrolldate< >

    GROUP BY a.empid

    ORDER BY a.empid

    ;

    If you use a WHERE clause to exclude the lines with some outstanding = 0 (or unpaid is NULL), then you would get no output for employees like empid = 2 in this example.  A WHERE clause ignores an entire line, so I used an expression BOX just a value.

  • Weeks of the month with Total

    Hey,.

    I try to display the weeks of the month based on values and a date.  I have a select statement that displays vertical to results, but I would like that they horizontally with the listed weeks. Below are the create table and insert instructions to help.  Once the start dates and end Dates are entered for one month, then the weeks should display with the counts for each Type Emp values and totals for each Type of Emp showing also. Any help is appreciated.  Thanks for taking a peek at my question.

    -Toad for Oracle 12.5

    CREATE TABLE TBL_EMP

      EMP_ID  NUMBER NOT NULL,

    FK_EMP_TYPE_ID NUMBER ,

    EMP_DATE DATE

    INSERT INTO TBL_EMP

    ()EMP_ID FK_EMP_TYPE_ID EMP_DATE( )

    (1, 100, TO_DATE('10/14/2014', 'MM/DD/YYYY'));

    INSERT INTO TBL_EMP

    ()EMP_ID FK_EMP_TYPE_ID EMP_DATE( )

    (2, 200, TO_DATE('10/12/2014', 'MM/DD/YYYY'));

    INSERT INTO TBL_EMP

    ()EMP_ID FK_EMP_TYPE_ID EMP_DATE( )

    (3, 200, TO_DATE('10/8/2014', 'MM/DD/YYYY'));

    INSERT INTO TBL_EMP

    ()EMP_ID FK_EMP_TYPE_ID EMP_DATE( )

    (4, 300, TO_DATE('10/15/2014', 'MM/DD/YYYY'));

    INSERT INTO TBL_EMP

    ()EMP_ID FK_EMP_TYPE_ID EMP_DATE( )

    (5, 100, TO_DATE('10/12/2014', 'MM/DD/YYYY'));

    INSERT INTO TBL_EMP

    ()EMP_ID FK_EMP_TYPE_ID EMP_DATE( )

    (6, 100, TO_DATE('9/9/2014', 'MM/DD/YYYY'));

     

    SELECT * DE TBL_EMP;

    -Can I display the vertical weeks but I would like that they horizontal

      SELECT 'WEEK ' || (TO_CHAR (EMP_DATE + 4, 'W')) WEEKS,

    FK_EMP_TYPE_ID ,

       COUNT (FK_EMP_TYPE_ID) AS EMP_TYPE_COUNT

       FROM TBL_EMP

       WHERE EMP_DATE BETWEEN TO_DATE ( :P10_START_DATE, 'MM/DD/YYYY')

       AND NVL (TO_DATE ( :P10_END_DATE, 'MM/DD/YYYY'), SYSDATE)

    GROUP BY 'WEEK ' || (TO_CHAR (EMP_DATE + 4, 'W')), FK_EMP_TYPE_ID

    ORDER BY WEEKS;

    -The values to enter for months

    -P10_START_DATE 10/01/2014

    -P10_END_DATE 31/10/2014

    -Results

    WEEK 2    200   1

    WEEK 3    100   2

    WEEK 3    200   1

    WEEK 3    300   1

     

      SELECT FK_EMP_TYPE_ID , COUNT (*)

       FROM TBL_EMP

       WHERE EMP_DATE BETWEEN TO_DATE ( :P10_START_DATE ' MM/DD/YYYY '( )

       AND NVL (TO_DATE ( :P10_END_DATE, 'MM/DD/YYYY'), SYSDATE)

    GROUP BY FK_EMP_TYPE_ID

    ORDER BY FK_EMP_TYPE_ID ASC;

    -Results

    FK_EMP_TYPE_ID COUNT(*)

    100                                  2

    200                                  2

    300                                  1

    -Results and horizontal display I want

    FK_EMP_TYPE_ID WEEK 1 WEEK 2 WEEK 3 WEEK 4 TOTALS

    100                                0               0            2            0             2

    200                                0               1            1            0             2

    300                                0               0            1            0             1

    Hello

    Select

    Here's one way:

    WITH relevant_data AS

    (

    SELECT fk_emp_type_id

    TO_CHAR (emp_date + 4, 'W') AS week_num - see note below

    OF tbl_emp

    WHERE the emp_date BETWEEN NVL (TO_DATE (: p10_start_date, ' MM/DD/YYYY'))

    SYSDATE - TRUNC (SYSDATE) or

    )

    AND NVL (TO_DATE (: p10_end_date, ' MM/DD/YYYY'))

    SYSDATE

    )

    )

    SELECT p

    week_1 + week_2 + week_3 + week_4 + week_5 AS totals

    OF relevant_data

    PIVOT (COUNT (*)

    FOR week_num IN ('1' AS week_1

    '2' AS week_2

    '3' AS week_3

    '4' AS week_4

    '5' AS week_5

    )

    ) p

    ORDER BY fk_emp_type_id

    ;

    Are you sure you want to add 4 days before calculating the week number?  If you're wondering the month of October 2014, for example, '1' of the week would include 1-3 October and from 28 to 31 October.  (4 days after October 28 is November 1, which is 1 week of November).

  • How to find lines that are inserted in the last minutes n?

    Hi all
    I have a log table where, whenever a warning is issued, a new row is added. The table contains a field with the sysdate when the warning was issued.
    I would need to collect all the warnings in the last 30 minutes (supposed) and send a mail to the administrator. Looking at some FAQ I have explained this:

    Select * from PROCEDURE_LOGS p where ((p.DATE_LOG-sysdate) *-1440) < 30

    However, it does not do anything.
    Can someone help me correct this statement?
    Thank you very much
    Frank

    Assuming that the field is a DATE field and time information are included in this field to date. Then your application should work.

    I would write it differently, but the logic is the same.

    select *
    from procedure_logs p
    where (sysdate - p.date_log) * 24 * 60 <= 30
    ;
    

    Perhaps the information is not yet committed, so that you don't see it in your additional session?

    Look at your data and consider wheather this record must be included or not.

  • get months with the maximum salary

    Hello

    I have the rest of the table.

    create table getmax)

    Select 1 empid, 2 month, 5000 in union wages double all the

    Select 1 empid, 10 months, the salary of 6,000 union double all the

    Select 1 empid, 12 months, 5500 in union wages double all the

    Select 2 empid, 3 months, the wages of 7000 Union double all the

    Select 2 empid, 7 months, the salary of 6,000 union double all the

    Select 2 empid, month 12, 5500 double salary

    );;

    I need to get employee of the month was the highest salary.

    Required result

    ========================

    EMPID MONTHS SALARY

    ========================

    1                10               6000

    2                 3                7000

    =======================

    Help, please.

    with

    getMax as

    (select empid 1, 2 months, 5000 in union wages double all the)

    Select 1 106 000 from all the double union

    Select 1 125 500 Union double all the

    Select 2,3,7000 from all the double union

    Select 2,7,6000 from all the double union

    Select double 2 125 500

    )

    Select empid, month, wages

    (select empid, month, salary)

    ROW_NUMBER() on rn (empid, salary desc order partition)

    of getmax

    )

    where rn = 1

    EMPID MNTH SALARY
    1 10 6000
    2 3 7000

    Concerning

    Etbin

  • grrrrr failed the icnd 1 last minute push irrelevant results either.

    I took the icnd1 to try to get it before the changes.  I got a 700 deaths was 802 I think.  Now what.  What is to be added and removed from the review of new.  They do not print a report score for me either. :(

    @diaczykmd1,
    Unlucky brother - it is a difficult test to pass when you are new to the world of networks. This will be the second time, they changed the syllabus for ICND1 and honestly, I wouldn't worry. The basic principles will be exactly the same. The most important thing with Cisco exams is to read each question carefully. Half of the questions you get wrong can often be because you misunderstood the question rather than to not know the answer. They like their word slyly.
    Study the new syllabus and resume.
    See you soon,.
    Luke
  • Nothing like to wait until the last minute...

    Passed VCP-510 today with a 444. Now certified in 3,4,5. Could not have done with this great community.

    Congratulations!

  • Alerts are have passed to the third-party tool with a some minutes along 2 late

    Hello

    I use this script to pass the Foglight alerts to a third-party tool:

    ServiceAlarms = #! FSMCategory: name = 'Test' # .topologyObjects [0] .aggregateAlarms

    found = ServiceAlarms.find {a-> a.alarmId == @event.get ("alarmID") ;}}

    If (found & @event.get ("severityLevel") > = 3 &)
    (@event.get("change/value") == 0) {}

    Returns true
    }

    This works successfully to transmit alerts for servers in the "Test" group and also as critical and fatal events without transmitting the events of compensation as it did before.

    But now the problem is that alert is get passed after about 2 minutes of being trigger who should not happpen and we want to get alerts immediately transmitted on fires.

    Help, please.

    Yes I use the script in the Condition of the rule.

Maybe you are looking for