List of day in a month

Hi,
I want to create a dynamic query that display the hours of each day in the current month in this format.
For example dd/mm/yyyy hh24:mi:ss
01/02/2010 01:00:00
01/02/2010 02:00:00
01/02/2010 03:00:00
02/02/2010 01:00:00
02/02/2010 02:00:00
02/02/2010 03:00:00
[...]from the first day to the last day in current month.
Some idea?
Thanks to all, as usual
Cheers,
Lain

SQL> select trunc(sysdate,'MM')+(level-1)/24 time
  2  from dual
  3  connect by level <= to_char(last_day(sysdate),'dd')*24;
TIME
01/02/2010 00:00:00
01/02/2010 01:00:00
01/02/2010 02:00:00
01/02/2010 03:00:00
01/02/2010 04:00:00
01/02/2010 05:00:00
01/02/2010 06:00:00
01/02/2010 07:00:00
01/02/2010 08:00:00
01/02/2010 09:00:00
01/02/2010 10:00:00
28/02/2010 18:00:00
28/02/2010 19:00:00
28/02/2010 20:00:00
28/02/2010 21:00:00
28/02/2010 22:00:00
28/02/2010 23:00:00
672 rows selected.Max
[My Italian Oracle blog| http://oracleitalia.wordpress.com/2010/02/07/aggiornare-una-tabella-con-listruzione-merge/]

Similar Messages

  • List all days of a month in single SQL

    I want a single SQL which should output
    01/Oct/2003
    02/Oct/2003
    30/Oct/2003
    31/Oct/2003
    Is that possible?

    I did:
    SQL> explain plan for
    2 select trunc(sysdate,'Mon') + rownum -1 from all_objects
    3 where rownum<=to_number(to_char(last_day(sysdate),'DD'));
    Uitleg is gegeven.
    SQL> select * from table(dbms_xplan.display());
    PLAN_TABLE_OUTPUT
    | Id | Operation | Name | Rows | Bytes | Cost |
    | 0 | SELECT STATEMENT | | | | |
    |* 1 | COUNT STOPKEY | | | | |
    |* 2 | FILTER | | | | |
    | 3 | TABLE ACCESS BY INDEX ROWID| OBJ$ | | | |
    | 4 | NESTED LOOPS | | | | |
    | 5 | TABLE ACCESS FULL | USER$ | | | |
    |* 6 | INDEX RANGE SCAN | I_OBJ2 | | | |
    |* 7 | TABLE ACCESS BY INDEX ROWID| IND$ | | | |
    |* 8 | INDEX UNIQUE SCAN | I_IND1 | | | |
    |* 9 | TABLE ACCESS BY INDEX ROWID| OBJAUTH$ | | | |
    | 10 | NESTED LOOPS | | | | |
    | 11 | FIXED TABLE FULL | X$KZSRO | | | |
    |* 12 | INDEX RANGE SCAN | I_OBJAUTH2 | | | |
    |* 13 | FIXED TABLE FULL | X$KZSPR | | | |
    |* 14 | FIXED TABLE FULL | X$KZSPR | | | |
    |* 15 | FIXED TABLE FULL | X$KZSPR | | | |
    |* 16 | FIXED TABLE FULL | X$KZSPR | | | |
    |* 17 | FIXED TABLE FULL | X$KZSPR | | | |
    |* 18 | FIXED TABLE FULL | X$KZSPR | | | |
    |* 19 | FIXED TABLE FULL | X$KZSPR | | | |
    |* 20 | FIXED TABLE FULL | X$KZSPR | | | |
    |* 21 | FIXED TABLE FULL | X$KZSPR | | | |
    |* 22 | FIXED TABLE FULL | X$KZSPR | | | |
    |* 23 | FIXED TABLE FULL | X$KZSPR | | | |
    |* 24 | FIXED TABLE FULL | X$KZSPR | | | |
    |* 25 | FIXED TABLE FULL | X$KZSPR | | | |
    |* 26 | FIXED TABLE FULL | X$KZSPR | | | |
    |* 27 | FIXED TABLE FULL | X$KZSPR | | | |
    |* 28 | FIXED TABLE FULL | X$KZSPR | | | |
    |* 29 | FIXED TABLE FULL | X$KZSPR | | | |
    Predicate Information (identified by operation id):
    1 - filter(ROWNUM<=TO_NUMBER(TO_CHAR(LAST_DAY(SYSDATE@!),'DD')))
    2 - filter(("SYS_ALIAS_2"."TYPE#"<>1 AND "SYS_ALIAS_2"."TYPE#"<>10 OR "
    PLAN_TABLE_OUTPUT
    SYS_ALIAS_2"."TYPE#"=1 AND (SELECT 1 FROM "SYS"."IND$" "I"
    WHERE "I"."OBJ#"=:B1 AND ("I"."TYPE#"=1 OR "I"."TYPE#"=2 OR
    "I"."TYPE#"=3 OR "I"."TYPE#"=4 OR "I"."TYPE#"=6 OR "I"."TYPE
    #"=7 OR "I"."TYPE#"=9))=1) AND ("SYS_ALIAS_2"."OWNER#"=:B2 O
    R "SYS_ALIAS_2"."OWNER#"=1 OR "SYS_ALIAS_2"."TYPE#"<>11 AND
    "SYS_ALIAS_2"."TYPE#"<>14 AND EXISTS (SELECT 0 FROM "SYS"."
    OBJAUTH$" "OBJAUTH$","X$KZSRO" "X$KZSRO" WHERE "OBJAUTH$"."O
    BJ#"=:B3 AND "OBJAUTH$"."GRANTEE#"="X$KZSRO"."KZSROROL" AND
    ("OBJAUTH$"."PRIVILEGE#"=3 OR "OBJAUTH$"."PRIVILEGE#"=6 OR "
    OBJAUTH$"."PRIVILEGE#"=7 OR "OBJAUTH$"."PRIVILEGE#"=9 OR "OB
    JAUTH$"."PRIVILEGE#"=10 OR "OBJAUTH$"."PRIVILEGE#"=12 OR "OB
    JAUTH$"."PRIVILEGE#"=11 OR "OBJAUTH$"."PRIVILEGE#"=16 OR "OB
    JAUTH$"."PRIVILEGE#"=17 OR "OBJAUTH$"."PRIVILEGE#"=18)) OR (
    "SYS_ALIAS_2"."TYPE#"=7 OR "SYS_ALIAS_2"."TYPE#"=8 OR "SYS_A
    LIAS_2"."TYPE#"=9 OR "SYS_ALIAS_2"."TYPE#"=28 OR "SYS_ALIAS_
    2"."TYPE#"=29 OR "SYS_ALIAS_2"."TYPE#"=30 OR "SYS_ALIAS_2"."
    TYPE#"=56) AND EXISTS (SELECT /*+ */ 0 FROM "X$KZSPR" "X$KZ
    SPR" WHERE "X$KZSPR"."KZSPRPRV"=1 AND "X$KZSPR"."INST_ID"=:B
    4 AND ((-"X$KZSPR"."INDX")=(-144) OR (-"X$KZSPR"."INDX")=(-1
    41))) OR "SYS_ALIAS_2"."TYPE#"=12 AND EXISTS (SELECT /*+ */
    0 FROM "X$KZSPR" "X$KZSPR" WHERE "X$KZSPR"."KZSPRPRV"=1 AND
    "X$KZSPR"."INST_ID"=:B5 AND (-"X$KZSPR"."INDX")=(-152)) OR
    "SYS_ALIAS_2"."TYPE#"=11 AND EXISTS (SELECT /*+ */ 0 FROM "
    X$KZSPR" "X$KZSPR" WHERE "X$KZSPR"."KZSPRPRV"=1 AND "X$KZSPR
    "."INST_ID"=:B6 AND (-"X$KZSPR"."INDX")=(-141)) OR "SYS_ALIA
    S_2"."TYPE#"=22 AND EXISTS (SELECT /*+ */ 0 FROM "X$KZSPR"
    "X$KZSPR" WHERE "X$KZSPR"."KZSPRPRV"=1 AND "X$KZSPR"."INST_I
    D"=:B7 AND ((-"X$KZSPR"."INDX")=(-189) OR (-"X$KZSPR"."INDX"
    )=(-190) OR (-"X$KZSPR"."INDX")=(-191) OR (-"X$KZSPR"."INDX"
    )=(-192))) OR ("SYS_ALIAS_2"."TYPE#"=1 OR "SYS_ALIAS_2"."TYP
    E#"=2 OR "SYS_ALIAS_2"."TYPE#"=4 OR "SYS_ALIAS_2"."TYPE#"=5
    OR "SYS_ALIAS_2"."TYPE#"=19 OR "SYS_ALIAS_2"."TYPE#"=20 OR "
    SYS_ALIAS_2"."TYPE#"=34 OR "SYS_ALIAS_2"."TYPE#"=35) AND EX
    ISTS (SELECT /*+ */ 0 FROM "X$KZSPR" "X$KZSPR" WHERE "X$KZSP
    R"."KZSPRPRV"=1 AND "X$KZSPR"."INST_ID"=:B8 AND ((-"X$KZSPR"
    ."INDX")=(-45) OR (-"X$KZSPR"."INDX")=(-47) OR (-"X$KZSPR"."
    INDX")=(-48) OR (-"X$KZSPR"."INDX")=(-49) OR (-"X$KZSPR"."IN
    DX")=(-50))) OR "SYS_ALIAS_2"."TYPE#"=6 AND EXISTS (SELECT
    /*+ */ 0 FROM "X$KZSPR" "X$KZSPR" WHERE "X$KZSPR"."KZSPRPRV"
    =1 AND "X$KZSPR"."INST_ID"=:B9 AND (-"X$KZSPR"."INDX")=(-109
    )) OR "SYS_ALIAS_2"."TYPE#"=13 AND EXISTS (SELECT /*+ */ 0
    PLAN_TABLE_OUTPUT
    FROM "X$KZSPR" "X$KZSPR" WHERE "X$KZSPR"."KZSPRPRV"=1 AND "X
    $KZSPR"."INST_ID"=:B10 AND ((-"X$KZSPR"."INDX")=(-184) OR (-
    "X$KZSPR"."INDX")=(-181))) OR "SYS_ALIAS_2"."TYPE#"=14 AND
    EXISTS (SELECT /*+ */ 0 FROM "X$KZSPR" "X$KZSPR" WHERE "X$KZ
    SPR"."KZSPRPRV"=1 AND "X$KZSPR"."INST_ID"=:B11 AND (-"X$KZSP
    R"."INDX")=(-181)) OR "SYS_ALIAS_2"."TYPE#"=23 AND EXISTS (
    SELECT /*+ */ 0 FROM "X$KZSPR" "X$KZSPR" WHERE "X$KZSPR"."KZ
    SPRPRV"=1 AND "X$KZSPR"."INST_ID"=:B12 AND ((-"X$KZSPR"."IND
    X")=(-177) OR (-"X$KZSPR"."INDX")=(-178))) OR "SYS_ALIAS_2".
    "TYPE#"=42 AND EXISTS (SELECT /*+ */ 0 FROM "X$KZSPR" "X$KZ
    SPR" WHERE "X$KZSPR"."KZSPRPRV"=1 AND "X$KZSPR"."INST_ID"=:B
    13 AND ((-"X$KZSPR"."INDX")=(-45) OR (-"X$KZSPR"."INDX")=(-4
    7) OR (-"X$KZSPR"."INDX")=(-48) OR (-"X$KZSPR"."INDX")=(-49)
    OR (-"X$KZSPR"."INDX")=(-50))) OR "SYS_ALIAS_2"."TYPE#"=32
    AND EXISTS (SELECT /*+ */ 0 FROM "X$KZSPR" "X$KZSPR" WHERE
    "X$KZSPR"."KZSPRPRV"=1 AND "X$KZSPR"."INST_ID"=:B14 AND ((-"
    X$KZSPR"."INDX")=(-205) OR (-"X$KZSPR"."INDX")=(-206) OR (-"
    X$KZSPR"."INDX")=(-207) OR (-"X$KZSPR"."INDX")=(-208))) OR "
    SYS_ALIAS_2"."TYPE#"=33 AND EXISTS (SELECT /*+ */ 0 FROM "X
    $KZSPR" "X$KZSPR" WHERE "X$KZSPR"."KZSPRPRV"=1 AND "X$KZSPR"
    ."INST_ID"=:B15 AND ((-"X$KZSPR"."INDX")=(-200) OR (-"X$KZSP
    R"."INDX")=(-201) OR (-"X$KZSPR"."INDX")=(-202) OR (-"X$KZSP
    R"."INDX")=(-203) OR (-"X$KZSPR"."INDX")=(-204))) OR "SYS_AL
    IAS_2"."TYPE#"=44 AND EXISTS (SELECT /*+ */ 0 FROM "X$KZSPR
    " "X$KZSPR" WHERE "X$KZSPR"."KZSPRPRV"=)
    6 - access("SYS_ALIAS_2"."OWNER#"="U"."USER#" AND "SYS_ALIAS_2"."LINKNA
    ME" IS NULL)
    filter("SYS_ALIAS_2"."LINKNAME" IS NULL AND "SYS_ALIAS_2"."NAME"<>'
    defaultauditing_options_' AND "SYS_ALIAS_2"."NAME"<>'_NEXT
    _OBJECT')
    7 - filter("I"."TYPE#"=1 OR "I"."TYPE#"=2 OR "I"."TYPE#"=3 OR "I"."TYPE
    #"=4 OR "I"."TYPE#"=6 OR "I"."TYPE#"=7 OR "I"."TYPE#"=9)
    8 - access("I"."OBJ#"=:B1)
    9 - filter("OBJAUTH$"."PRIVILEGE#"=3 OR "OBJAUTH$"."PRIVILEGE#"=6 OR "O
    BJAUTH$"."PRIVILEGE#"=7 OR "OBJAUTH$"."PRIVILEGE#"=9 OR "OBJ
    AUTH$"."PRIVILEGE#"=10 OR "OBJAUTH$"."PRIVILEGE#"=12 OR "OBJ
    AUTH$"."PRIVILEGE#"=11 OR "OBJAUTH$"."PRIVILEGE#"=16 OR "OBJ
    AUTH$"."PRIVILEGE#"=17 OR "OBJAUTH$"."PRIVILEGE#"=18)
    12 - access("OBJAUTH$"."GRANTEE#"="X$KZSRO"."KZSROROL" AND "OBJAUTH$"."O
    BJ#"=:B1)
    13 - filter("X$KZSPR"."KZSPRPRV"=1 AND "X$KZSPR"."INST_ID"=:B1 AND ((-"X
    PLAN_TABLE_OUTPUT
    $KZSPR"."INDX")=(-144) OR (-"X$KZSPR"."INDX")=(-141)))
    14 - filter("X$KZSPR"."KZSPRPRV"=1 AND "X$KZSPR"."INST_ID"=:B1 AND (-"X$
    KZSPR"."INDX")=(-152))
    15 - filter("X$KZSPR"."KZSPRPRV"=1 AND "X$KZSPR"."INST_ID"=:B1 AND (-"X$
    KZSPR"."INDX")=(-141))
    16 - filter("X$KZSPR"."KZSPRPRV"=1 AND "X$KZSPR"."INST_ID"=:B1 AND ((-"X
    $KZSPR"."INDX")=(-189) OR (-"X$KZSPR"."INDX")=(-190) OR (-"X
    $KZSPR"."INDX")=(-191) OR (-"X$KZSPR"."INDX")=(-192)))
    17 - filter("X$KZSPR"."KZSPRPRV"=1 AND "X$KZSPR"."INST_ID"=:B1 AND ((-"X
    $KZSPR"."INDX")=(-45) OR (-"X$KZSPR"."INDX")=(-47) OR (-"X$K
    ZSPR"."INDX")=(-48) OR (-"X$KZSPR"."INDX")=(-49) OR (-"X$KZS
    PR"."INDX")=(-50)))
    18 - filter("X$KZSPR"."KZSPRPRV"=1 AND "X$KZSPR"."INST_ID"=:B1 AND (-"X$
    KZSPR"."INDX")=(-109))
    19 - filter("X$KZSPR"."KZSPRPRV"=1 AND "X$KZSPR"."INST_ID"=:B1 AND ((-"X
    $KZSPR"."INDX")=(-184) OR (-"X$KZSPR"."INDX")=(-181)))
    20 - filter("X$KZSPR"."KZSPRPRV"=1 AND "X$KZSPR"."INST_ID"=:B1 AND (-"X$
    KZSPR"."INDX")=(-181))
    21 - filter("X$KZSPR"."KZSPRPRV"=1 AND "X$KZSPR"."INST_ID"=:B1 AND ((-"X
    $KZSPR"."INDX")=(-177) OR (-"X$KZSPR"."INDX")=(-178)))
    22 - filter("X$KZSPR"."KZSPRPRV"=1 AND "X$KZSPR"."INST_ID"=:B1 AND ((-"X
    $KZSPR"."INDX")=(-45) OR (-"X$KZSPR"."INDX")=(-47) OR (-"X$K
    ZSPR"."INDX")=(-48) OR (-"X$KZSPR"."INDX")=(-49) OR (-"X$KZS
    PR"."INDX")=(-50)))
    23 - filter("X$KZSPR"."KZSPRPRV"=1 AND "X$KZSPR"."INST_ID"=:B1 AND ((-"X
    $KZSPR"."INDX")=(-205) OR (-"X$KZSPR"."INDX")=(-206) OR (-"X
    $KZSPR"."INDX")=(-207) OR (-"X$KZSPR"."INDX")=(-208)))
    24 - filter("X$KZSPR"."KZSPRPRV"=1 AND "X$KZSPR"."INST_ID"=:B1 AND ((-"X
    $KZSPR"."INDX")=(-200) OR (-"X$KZSPR"."INDX")=(-201) OR (-"X
    $KZSPR"."INDX")=(-202) OR (-"X$KZSPR"."INDX")=(-203) OR (-"X
    $KZSPR"."INDX")=(-204)))
    25 - filter("X$KZSPR"."KZSPRPRV"=1 AND "X$KZSPR"."INST_ID"=:B1 AND ((-"X
    $KZSPR"."INDX")=(-222) OR (-"X$KZSPR"."INDX")=(-223)))
    26 - filter("X$KZSPR"."KZSPRPRV"=1 AND "X$KZSPR"."INST_ID"=:B1 AND (-"X$
    KZSPR"."INDX")=12)
    27 - filter("X$KZSPR"."KZSPRPRV"=1 AND "X$KZSPR"."INST_ID"=:B1 AND ((-"X
    $KZSPR"."INDX")=(-251) OR (-"X$KZSPR"."INDX")=(-252) OR (-"X
    $KZSPR"."INDX")=(-253) OR (-"X$KZSPR"."INDX")=(-254)))
    28 - filter("X$KZSPR"."KZSPRPRV"=1 AND "X$KZSPR"."INST_ID"=:B1 AND ((-"X
    $KZSPR"."INDX")=(-65) OR (-"X$KZSPR"."INDX")=(-66) OR (-"X$K
    ZSPR"."INDX")=(-67) OR (-"X$KZSPR"."INDX")=(-68)))
    PLAN_TABLE_OUTPUT
    29 - filter("X$KZSPR"."KZSPRPRV"=1 AND "X$KZSPR"."INST_ID"=:B1 AND ((-"X
    $KZSPR"."INDX")=(-246) OR (-"X$KZSPR"."INDX")=(-247) OR (-"X
    $KZSPR"."INDX")=(-248) OR (-"X$KZSPR"."INDX")=(-249)))
    Note: rule based optimization
    169 rijen zijn geselecteerd.
    SQL>

  • View Outlook Calendar on iPhone In Day, Week, Or Month Views--NOT As A List

    I apologize in advance if this has been asked already but couldn't find the answer after an extensive search.
    My question is, after syncing my Outlook calendar to the iPhone, how can I view my appointments other than as a list in the iPhone? I would like to view my appointments in either day, week, or month views as opposed to only knowing what my next two or three appointments are. To me it just seems like a simple setting I'm overlooking somewhere. I appreciate any help you can afford
    Thanks in advance,
    -V5

    *iPhone calendar views are a joke!*
    My 90's Palm Vx had far more usable views via Pimlico Software. The gray scale display with poor resolution was able to show one or even two weeks with appointment texts.
    What does iPhone have? List view is the best there is. One sees all appointments with only just scrolling. Day view is terrible. The whole day should be visible without scrolling for it to be at least somewhat efficient. Now one has to first select a day with arrows and after that scroll thru the day and after that select another day and scroll again. No way. Month view is very poorly designed! The grid takes way too much space and who decided to put the appointment list in the bottom of the screen when one's index finger blocks it if sliding thru days in the grid!!! Oh man!!! Unlock the landscape view and please make the grid a little bit smaller and please place the appointment list on the left or at least on the right side. And make its font way smaller! No point in seeing two appoinments without scrolling.
    iPhone's wonderful screen would be able to show one or two weeks with written appointments in a list like manner especially landscape. I mean seven columns titled Mo-Su and all appointments listed in that day's column.
    Hopefully SDK will let someone else do it if Apple won't.
    And we have to get to copy appointments and paste them to other days also. I am spending 30 min writing the same info one at a time to our monthly plan. Everyone else is already having a cup of coffee.

  • SQL help: return number of records for each day of last month.

    Hi: I have records in the database with a field in the table which contains the Unix epoch time for each record. Letz say the Table name is ED and the field utime contains the Unix epoch time.
    Is there a way to get a count of number of records for each day of the last one month? Essentially I want a query which returns a list of count (number of records for each day) with the utime field containing the Unix epoch time. If a particular day does not have any records I want the query to return 0 for that day. I have no clue where to start. Would I need another table which has the list of days?
    Thanks
    Ray

    Peter: thanks. That helps but not completely.
    When I run the query to include only records for July using a statement such as following
    ============
    SELECT /*+ FIRST_ROWS */ COUNT(ED.UTIMESTAMP), TO_CHAR((TO_DATE('01/01/1970','MM/DD/YYYY') + (ED.UTIMESTAMP/86400)), 'MM/DD') AS DATA
    FROM EVENT_DATA ED
    WHERE AGENT_ID = 160
    AND (TO_CHAR((TO_DATE('01/01/1970','MM/DD/YYYY')+(ED.UTIMESTAMP/86400)), 'MM/YYYY') = TO_CHAR(SYSDATE-15, 'MM/YYYY'))
    GROUP BY TO_CHAR((TO_DATE('01/01/1970','MM/DD/YYYY') + (ED.UTIMESTAMP/86400)), 'MM/DD')
    ORDER BY TO_CHAR((TO_DATE('01/01/1970','MM/DD/YYYY') + (ED.UTIMESTAMP/86400)), 'MM/DD');
    =============
    I get the following
    COUNT(ED.UTIMESTAMP) DATA
    1 07/20
    1 07/21
    1 07/24
    2 07/25
    2 07/27
    2 07/28
    2 07/29
    1 07/30
    2 07/31
    Some dates donot have any records and so no output. Is there a way to show the missing dates with a COUNT value = 0?
    Thanks
    Ray

  • Count days in a month for a date range

    i am trying to find no. of days between 2 Date Ranges for a list of Ids. i used the logic in the below link:
    count days of the month
    My query is giving duplicates since, I have list of Ids.
    Doctor_ID     Patient_ID     ARRIVE_DT_TM     DISCH_DT_TM
    755722     42972229     10/18/2012 7:50     3/14/2013 20:45
    763305     42972232     1/7/2013 20:27     3/15/2013 19:15
    25391509     42972298     2/4/2013 22:45     3/8/2013 22:03
    746779     42972331     1/4/2013 23:00     3/26/2013 21:50
    763305     42972338     3/4/2013 22:19     3/6/2013 19:35
    763305     42972411     11/4/2013 22:32     3/29/2013 17:30
    I am looking for query to give me for Patient_ID = 42972229
    MONTH     COUNT_DAYS
    201210     14
    201211     30
    201212     31
    201301     31
    201302     28
    201303     14
    I am running the following code and it loops through the months and gives duplicates when I remove where Patient_id IN (42972229)
    select
    Doctor_ID
    , Patient_ID
    , AR_DTTM
    , DSC_DTTM
    , TO_CHAR(ADD_MONTHS(TRUNC(date1, 'MONTH'), LEVEL - 1), 'YYYY MM') MONTHS_BET
    , (LEAST(date2, ADD_MONTHS(TRUNC(date1, 'MONTH') - 1, LEVEL)) - GREATEST(date1, ADD_MONTHS(TRUNC(date1, 'MONTH'), LEVEL - 1)))+ 1 AS DAYSCOUNT
    from (select
    Doctor_ID
    , Patient_ID
    , ARRIVE_DT_TM AR_DTTM
    , DISCH_DT_TM DSC_DTTM
    ,TRUNC(ARRIVE_DT_TM,'DDD') AS date1
    ,TRUNC(DISCH_DT_TM,'DDD') AS date2
    from temp where Patient_id IN (42972229)
    CONNECT BY LEVEL <= MONTHS_BETWEEN(TRUNC(date2, 'MONTH'), TRUNC(date1, 'MONTH')) + 1
    Please help!

    Hi,
    ASTRA_007 wrote:
    Results I would like to see are:
    Doctor_ID     Patient_ID     ARRIVE_DT_TM     DISCH_DT_TM     Month     CountofDays
    755722     42972229     10/18/2012 7:50     3/14/2013 20:45     2012 10     14
    755722     42972229     10/18/2012 7:50     3/14/2013 20:45     2012 11     30
    755722     42972229     10/18/2012 7:50     3/14/2013 20:45     2012 12     31
    755722     42972229     10/18/2012 7:50     3/14/2013 20:45     2013 01     31
    755722     42972229     10/18/2012 7:50     3/14/2013 20:45     2013 02     28
    755722     42972229     10/18/2012 7:50     3/14/2013 20:45     2013 03     14
    763305     42972232     1/7/2013 20:27     3/15/2013 19:15     2013 01     25
    763305     42972232     1/7/2013 20:27     3/15/2013 19:15     2013 02     28
    763305     42972232     1/7/2013 20:27     3/15/2013 19:15     2013 03     15
    and so on...So each row represents a patient-month, and you want to display several columns from the temp table on each output row. In that case, include all those columns in both the SELECT and GROUP BY clauses, like this:
    WITH     universe     AS
         SELECT     *
         FROM     temp
    --     WHERE     patient_id     IN (42972229)
    ,     date_range     AS
         SELECT     TRUNC (MIN (arrive_dt_tm))     AS first_date
         ,     TRUNC (MAX (disch_dt_tm))     AS last_date
         FROM     universe
    ,     all_dates     AS
         SELECT     first_date + LEVEL - 1     AS a_date
         FROM     date_range
         CONNECT BY     LEVEL     <= (last_date + 1) - first_date
    SELECT    u.doctor_id
    ,       u.patient_id
    ,       u.arrive_dt_tm
    ,       u.disch_dt_tm
    ,       TO_CHAR ( TRUNC (a.a_date, 'MONTH')
                  , 'YYYY MM'
                )          AS month
    ,       COUNT (*)          AS count_days
    FROM       all_dates  a
    JOIN       universe   u  ON  a.a_date  BETWEEN  TRUNC (u.arrive_dt_tm)
                                         AND      u.disch_dt_tm
    GROUP BY  u.doctor_id
    ,       u.patient_id
    ,       u.arrive_dt_tm
    ,       u.disch_dt_tm
    ,         TRUNC (a.a_date, 'MONTH')
    ORDER BY  u.patient_id
    ,       TRUNC (a.a_date, 'MONTH')
    ;Output from your sample data (with no filtering):
    `DOCTOR_ID PATIENT_ID ARRIVE_DT_TM     DISCH_DT_TM      MONTH   COUNT_DAYS
        755722   42972229 10/18/2012 7:50  3/14/2013 20:45  2012 10         14
        755722   42972229 10/18/2012 7:50  3/14/2013 20:45  2012 11         30
        755722   42972229 10/18/2012 7:50  3/14/2013 20:45  2012 12         31
        755722   42972229 10/18/2012 7:50  3/14/2013 20:45  2013 01         31
        755722   42972229 10/18/2012 7:50  3/14/2013 20:45  2013 02         28
        755722   42972229 10/18/2012 7:50  3/14/2013 20:45  2013 03         14
        763305   42972232 1/7/2013 20:27   3/15/2013 19:15  2013 01         25
        763305   42972232 1/7/2013 20:27   3/15/2013 19:15  2013 02         28
        763305   42972232 1/7/2013 20:27   3/15/2013 19:15  2013 03         15
      25391509   42972298 2/4/2013 22:45   3/8/2013 22:3    2013 02         25
      25391509   42972298 2/4/2013 22:45   3/8/2013 22:3    2013 03          8
        746779   42972331 1/4/2013 23:0    3/26/2013 21:50  2013 01         28
        746779   42972331 1/4/2013 23:0    3/26/2013 21:50  2013 02         28
        746779   42972331 1/4/2013 23:0    3/26/2013 21:50  2013 03         26
        763305   42972338 3/4/2013 22:19   3/6/2013 19:35   2013 03          3
    In the end the objective is to count the no. of days in each month between the arrival and discharge dates by Physician and for his/her patients.Then is the output above really what you want? Say you're interested in physician 763305. That physician had 18-patient days in March, 2013, but the output doesn't make it clear.
    I ran your query, it works great but I have a long list of patients for whom I have to run these counts.the query above includes all patient_ids.
    That's a separate problem, to be solved in the first sub-query, universe. The rest of the query will be unchanged.
    How will you know which patients to include? If you can derive the list from temp itself, just use a WHERE clause in universe. If you need to look at other tables, join them in universe, or use them in sub-queries in universe, or both.
    For exmple, if you decide that the list of patient_ids has no pattern, and that you'll need to store their ids in a separate table (perhaps a global temporary table), then universe might be:
    WITH     universe     AS
         SELECT     t.*     -- or list columns needed
         FROM     temp                        t
         JOIN     patient_ids_to_include  p 
                      ON  p.patient_id = t.patient_id
    ) ...The rest of the query can be the same as above.
    If a same patient is admitted again then Patient_ID will be different no matter when readmitted.Are you saying that patient_id identifies a visit, not a patient, and that the same person is assigned a different patient_id every time that person is admitted?
    For
    INSERT INTO temp (doctor_id, patient_id, arrive_dt_tm, disch_dt_tm)
    VALUES ( 755722
    , 42972229
    , TO_DATE ('03/14/2013 23:00', 'MM/DD/YYYY HH24:MI')
    , TO_DATE ('04/01/2013 12:00', 'MM/DD/YYYY HH24:MI')
    First the Patient ID will be different from the earlier admission. Second the results will show like:
    Doctor_ID     Patient_ID     ARRIVE_DT_TM     DISCH_DT_TM     Month     CountofDays
    755722     42972229     3/14/2013 23:00     4/1/2013 12:00     2012 03     14
    755722     42972229     3/14/2013 23:00     4/1/2013 12:00     2012 04     1Are you saying that temp.patient_id is unique, and so the situation is impossible?
    Edited by: Frank Kulash on May 7, 2013 10:23 AM

  • Why did my calendar view suddenly change? Using iOS 7.1 and I've been using this version for a few weeks with no problem with my calendar. Now the view has changed and I can't view a list mode without seeing the month too

    Why did my calendar view suddenly change in iCal? I've been using ios7 fôr a few weeks now with no problems. Suddenly, without any updates or anything, the calendar view changed and I can no longer view it as a list without having the entire month seen as well.

    Hey Gattypyle,
    Thanks for the question. You simply need to go back to Day/Week view, then tap the list-view icon once more.
    Calendar at a glance - iPhone
    http://help.apple.com/iphone/7/#/iph3d110f84
    View a list of events. In month view, tap to see a day’s events. In day view, Tap the to view a list of events.
    Thanks,
    Matt M.

  • Amount of days in each month

    Post Author: mike7510uk
    CA Forum: Formula
    i have a report where i have the days of the month along the top. I use this formula to get the day number
    ... int(day(DateAdd ("D",0,cdate({Command_1.startdate} )))) ...
    where the 0 is incremented along the report up to 30. The startdate bit of the formula is a pre-defined date such as 01-04-2007 (1st april)
    The fields then all work up to the point of 30th, i need it to end there and not go into the next month (1st)
    Obviously this is fine if the month has 31 days as it will just display 1-31. I need some IF statements maybe that looks at which month is selected and displays the correct amount of days.
    Any ideas?

    Post Author: SKodidine
    CA Forum: Formula
    The easiest way to get the last day of the month (and hence the number of days in a month) is to use the custom function that comes with CR.  I have only worked with CR XI so not sure about other versions.
    1. Open the formula workshop.
    2. From the Repository Custom Functions, under Crystal and then Date, RIGHT click on cdlastdayofmonth, click on ADD TO REPORT.
    3. Create a new formula, in the formula workshop, under FUNCTIONS, go down the list till you see "CUSTOM FUNCTIONS", expand that till you see cdlastdayofmonth.
    4.  In your formula, type cdlastdayofmonth(currentdate)
    5. Save and close and display the formula in your report, you should see 04/26/2007, depending on your date format.
    You can customize the formula to suit your needs, and this way you do not have to worry about leap years..

  • How to run procedure/job only on third business day of the month

    Hello All,
    how can i run the procedure/job only third business day of the month? I am using month table in my procedure and it gets updated only once in month and procedure doesn't need to run everyday.

    >
    how can i run the procedure/job only third business day of the month? I am using month table in my procedure and it gets updated only once in month and procedure doesn't need to run everyday.
    >
    For such a sparse schedule the easiest way is to DBMS_SCHEDULER and set the 'repeat_interval' using the BYDATE parameter.
    See Table 14-7 in chapter 114 DBMS_SCHEDULER of the PL/SQL Packages and Types doc
    http://docs.oracle.com/cd/B28359_01/appdev.111/b28419/d_sched.htm#BABEJGCH
    >
    Table 114-7 Values for repeat_interval
    BYDATE
    This specifies a list of dates, where each date is of the form [YYYY]MMDD. A list of consecutive dates can be generated by using the SPAN modifier, and a date can be adjusted with the OFFSET modifier. An example of a simple BYDATE clause is the following:
    BYDATE=0115,0315,0615,0915,1215,20060115
    The following SPAN example is equivalent to BYDATE=0110,0111,0112,0113,0114, which is a span of 5 days starting at 1/10:
    BYDATE=0110+SPAN:5D
    The plus sign in front of the SPAN keyword indicates a span starting at the supplied date. The minus sign indicates a span ending at the supplied date, and the "^" sign indicates a span of n days or weeks centered around the supplied date. If n is an even number, it is adjusted up to the next odd number.
    Offsets adjust the supplied date by adding or subtracting n days or weeks. BYDATE=0205-OFFSET:2W is
    >
    The chapter has examples.

  • Counts entry days within a month.

    I keep a list of days that I work for a certain company. There are about 50 dates in a column (ie: 04/13/10, 04/28/10, 05/02/10, etc.). I want to count how many days worked are in January, February, March, .... How do I do this?

    Hi Erik,
    Welcome to Apple Discussions and the Numbers '09 forum.
    =IF(ISBLANK(Date),"",(MONTHNAME(MONTH(Date))))
    extracts the month (number) than converts it to the monthname.
    =YEAR(Date)
    extracts the year.
    If you want both in the same cell, you'll need to concatenate the two results, separating them with whatever text you want.
    =IF(ISBLANK(Date),"",(MONTHNAME(MONTH(Date))&", "&YEAR(Date)))
    Date here is the cell in the column headed Date, in the same row as the cell containing the formula. 
    One of the best pieces of advice I can give a new user of Numbers, which I'm assuming from this being your first post to the forum,you are, is to spend an hour or so reading/browsing the Numbers '09 User Guide. If you haven't already done so, go to the Help menu in Numbers and download that guide, and the iWork formulas and Functions User Guide. Both are well written, the Numbers guide gives an overview of the applications design and features, and the Formulas and Functions guide describes each of the functions supported in Numbers (and in tables in the other iWork applications), with examples of how each works. The Date and Time functions, including MONTH, MONTHNAME AND YEAR are discussed (with further examples) in Chapter 3.
    Regards,
    Barry

  • Report for current day and current month

    Hi gurus,
    i 've a report, where i 've to display the values for qty and cost of the material for the current day and current month
    HOw can i do this in BEx Query designer..If any document plz share
    thanks
    rakesh

    hi Kolli
    here i want to filter the data on system date,
    i wnt the report to pick the date dynamically based on the system date.
    but i think restricting on calmonth and calday is not going to solve my scenario..
    rakesh

  • How can I set an event to repeat on a week day rather than a numerical day of each month?

    How can I set an event to repeat on a week day rather than a numerical day of each month? I see an option at the bottom of the repeat window .... but I cannot use it. Actually, when I try it freezes up my Calendar.
    Lorrene Baum Davis

    These scrrenshots are from Snow Leopard - I would think that Lion wouldn't be too much different.

  • Defining last day of previous month in ABAP

    All,
    I am a BW guy and hardly know ABAP. I have a requirement where I have to calculate last day of previous month and use it in the routines of the transformations.
    I have decided to define the Last day of previous month in Start routine and then use the global variable in Transformations to calculate further.
    The logic that i have used is outlined below.
             Define G_DATE in global declaration for further use in Transformations.
    In the Routine section,
            Assign G_DATE to SY-DATUM
            G_DATE + 6(2) = '01' (Replace last to field of date with '01' to establish first day of the current month)
            G_DATE = G_DATAE - 1 (To get to last day of previous month)
    My dilemma is to implement this in ABAP in Start routine of transformations. Please include the exact ABAP code that would be needed in Declarations and Routine section.
    Thanks in advance.

    Hi..,
    Go with the function module: LAST_DAY_OF_MONTHS
    So, Just determine the last month from the sy-datum and then use above function module and pick the last date of the month.
    Thanks,
    Naveen Inuganti.

  • Successive dates with  last day of that month being added to succesive date

    Hi ,
    I have a piece of code that displays the succuessive dates from the given date to tilll date with a date interval of 30 days. My requirement goes some thing like this. since the given date is '26-nov-08' the next successive date should be the number of days in nov(30) added to '26-nov-08'. that will be around 26-dec-08. For this date it has to add the number of days in December(31) to '26-dec-08' and that turns out to be '26-jan-09'. and this must go on till date.
    In the below code i have used 30 for the interval of 30 days but the interval has to the last day of the successive date's month( for dec the interval has to 31 and for january the interval has to be 31 and for february 28)
    select to_date('26-nov-08', 'dd-mon-yy') + (level - 1) * 30
    from dual
    connect by level <= trunc((sysdate-to_date('26-nov-08', 'dd-mon-yy'))/30 )Please advice

    hi ,
    the query sent by you is correct and could it be in corporated for this query :
    SELECT TRUNC(inst_due_date) + (LEVEL-1 ) * (ilpa_term_type),iloan_code,LOAN_AMT,FEE_AMT,
    LOAN_DATE,LOAN_STATUS_ID
    FROM (
    SELECT inst_due_date,sm.iloan_code,LOAN_AMT,
    FEE_AMT,
    LOAN_DATE,
    LOAN_STATUS_ID,
    decode(sm.ilp_term_type, 26 ,14,24,15,12,(select to_number(to_char(last_day(inst_due_date),'dd')) from dual)) as ilpa_term_type
    FROM ST_IL_SCHEDULE sc,ST_IL_MASTER sm
    WHERE sc.iloan_code = sm.iloan_code
    AND sc.inst_num = (SELECT MAX(inst_num) FROM ST_IL_SCHEDULE b WHERE b.iloan_code = sc.iloan_code)
    AND sc.iloan_code =123456789)
    CONNECT BY LEVEL <= TRUNC((TRUNC(SYSDATE)-TRUNC(inst_due_date))/(ilpa_term_type) )
    Here we are using the decode concept if ilp_term_type = 26 then 14 but we need to implement the code of adding the number of days to that month in place of this code :
    select to_number(to_char(last_day(inst_due_date),'dd')) from dual:
    Please advice

  • Display a metric differently only on last day of the month.

    Have a Daily transaction fact where unit cost of product is stored at a day/part num /business unit level.
    When we drag and drop date column and unit cost in the report like below we will have
    Date      cost
    Sep29     $10
    sep30     $12
    Oct1       $12
    Oct2       $14
    ..........ans so on
    The source sustem program runs on last day of the month around 8pm for setting up cost to reflect on 1st of every month
    But the nighly OBI load ( Runs at 2am every day) when incrementally updating Sep30 data picks up $12 from the erp and populates in OBI.
    But actually speaking, on Sep30 the cost was $10.
    There is no way of running the ERP program to run afer OBI load. Hence we need an expression in the RPD (not answers) saying
    when last day of the month (any month) the standard cost must be a previous day value.All other days the same value should be returned.
    Is this possible without impacting report performance ?
    So, when we drag and drop date and cost value the above report should change as
    Date        Cost
    sep29     $10
    sep30     $10
    Oct1       $12
    Oct2       $14
    Oct30     $12.5
    Oct31     $12.5
    Nov1      $13.5

    You can achieve the above requirement for current month alone with below steps:
    The solution requires to have a union report
    First part of the report will have Date and Cost fields with a report level date filter, Date NOT IN (TIMESTAMPADD( SQL_TSI_DAY , -(1), TIMESTAMPADD( SQL_TSI_MONTH , 1, TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE))))
    Second part of the report will have Date and Cost fields with a report level date filter Date IN (TIMESTAMPADD( SQL_TSI_DAY , -(1), TIMESTAMPADD( SQL_TSI_MONTH , 1, TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE))))In the second part of the report,
    Change the column formula for Date to display only Current_Date
    Change the column formula for Cost field with FILTER(Cost USING Date = Current_Date-1)
    Pls mark if correct/helpful.

  • How to calculate the number of days until your next birthday. Only using current month, day and birth month and day.

    I'm trying to calculate the number of days until your next birthday. Only using current month, day and birth month and day. I can get close but i'm way off. When i enter in the next day, the amount of days is supposed to be 364. This is where I am having problems. I know my code is way off. I just need some guidance please!
    Attachments:
    D5.7_1.vi ‏8 KB

    I just had a little fun with the Time Record...
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines
    Attachments:
    D5.7_1_BD.png ‏19 KB

Maybe you are looking for

  • Scope differential clock

    Hello, I am working with Vivado 2015.1 and a ZC706 board. I want to scope the differential clock that comes as input to pins W8 (SMA_MGT_REFCLK_P) and W7 (SMA_MGT_REFCLK_N). I have contstrained the pins as follows in the xdc file: set_property PACKAG

  • Processing EIC follow up via the Universal Worklist (UWL)

    Hi We are implemented EIC (Employee Interationc Centre) ERP and have an issue whereby the follow up appears in both the agent inbox within EIC and the Universal Worklist.   The workflow for follow up is WS61000086.  How do we get the follow up to wor

  • Editing and uploading

    I created a page in iWeb and published it on iPage. The upload was messed up and I talked to iPage who told me something about an ampersand and Unix that caused the problem and they were able to do something at their end that corrected the problem in

  • Help in AS3 Sprite

    Hello All, I got this Error : 1061: Call to a possibly undefined method addChild through a reference with static type Class. what I'm trying to do : I have create a new class called Graph and make it extends Sprite and  add a scroolpane to my stage a

  • JDBC connect to Oracle, IO exception, Help!

    I am trying to connect to Oracle server via JDBC, but encountered IO exception problem, could anyone provide me any help? code is as follows: String url ="jdbc:oracle:thin:@IP:1521:oracleSID" Class.forName ("oracle.jdbc.driver.OracleDriver"); con = D