SQL to display Mon-sun

I need a SQL to display Mon-sun in a week when enter a date. If i give '24-Mar-2011' i want Mon-sun dates displayed i.e from 21-Mar-2011 to 27-Mar-2011.

Even thought this question is many asked times I decided to post this time.
From next time if you could search the forum it will be much appreciated.
SQL> select * from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
PL/SQL Release 10.2.0.4.0 - Production
CORE    10.2.0.4.0      Production
TNS for 64-bit Windows: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production
SQL> alter session set nls_Date_Format = 'DD-MON-YYYY';
Session altered.
SQL> with t
  2  as
  3  (
  4   select next_day(to_date('&Enter_Date','dd.mm.yyyy') - 7, 'SUN') start_date from dual
  5  )
  6  select start_date + level from t
  7  connect by level <= 7
  8  /
Enter value for enter_date: 24.03.2011
old   4:  select next_day(to_date('&Enter_Date','dd.mm.yyyy') - 7, 'SUN') start_date from dual
new   4:  select next_day(to_date('24.03.2011','dd.mm.yyyy') - 7, 'SUN') start_date from dual
START_DATE+
21-MAR-2011
22-MAR-2011
23-MAR-2011
24-MAR-2011
25-MAR-2011
26-MAR-2011
27-MAR-2011
7 rows selected.Thanks
Raj

Similar Messages

  • Calendar Days  Mon-Sun vs Sun-Sat

    For some reason my calendar started showing the days as Mon-Sun instead of Sun - Sat on the monthly display. I have know idea why. Any thoughts on how I can change it back?

    Check Settings -> General -> International -> Region Format.
    Be sure it is set to United States. It sounds like it is set to United Kingdom where weeks are Mon-Sun.

  • Can anybody help....SQL to display row as column and column as rows

    Can anybody help in writing a SQL to display row as column and column as rows?
    Thanks

    check this link:
    Re: Creating Views - from rows to a new column?

  • Format of sum of integers in sql query displayed in table as decimal

    I created a table with data from a RowSet. One of the columns is based on the sql sum function. The sum function is on a table column of integers (games.score) and is bound to a staticText column with #{currentRow.value['sum(games.score)']}
    Although this is a sum of integers the staticText component displays this in the table as a decimal--123.0 shows up in the column rather than the desired 123 when in design view. Can anyone tell me how to change this formatting from decimal to integer? I cannot see where to do this using the properties of a staticText component.

    Hi,
    You can try to convert your sum value to string directly into the sql statement.
    For example, in Oracle, to_char(sum(games.score)).
    I use this method to display short dates instead of sql timestamp in table columns: to_char(datefield, 'DD-MON-YYYY') as datefield.
    Hope this helps,
    Catalin Florean.

  • Default Value is not getting displayed in SUN ONE Ldap

    Hello,
    I have created an attribute in slapd.user_at.conf and it is associated in slapd.user_oc.conf.
    The attribute default value is given through SUN ONE Console. But, In our application the default value is not getting displayed.
    We need the default value to run our applicatin. Can anyone help me for this issue
    Regards,
    K. Senthil Kumar

    Hi anandkumar,
    I belive this issue can be resolved by changing the  Query proprties for the perticular field.
    Kindly check the Field proerties in query designer and ensure that Text is enabled ather than Key.
    __Field property check up:__Go to query designer->click onn the field-> Right hand side in properties click on display tab-> select Text in drop down menu of Display as tab.
    FURTHER CHECK UP: check the master data avaiulability for the perticular info object, if masterdata is not available, do the text data for txt data availability in report level.
    Hope this helps you!!
    Best Regards,
    Maruthi

  • Sql to display output in Horizontal view

    Experts,
    I need to display the sql query output in horizontal manner. Below I have given the script.
    create table TestTable (id number, name varchar2(10))
    insert into TestTable values (1, 'John')
    insert into TestTable values (2, 'Mckensy')
    insert into TestTable values (3, 'Valneech')
    insert into TestTable values (4, 'Zeebra')
    commit
    select * from TestTable
    Getting output in Vertical View.
    ID Name
    1 John
    2 Mckensy
    3 Valneech
    4 Zeebra
    But for my requirement, I need to display in horizontal manner.
    ID   1       2       3           4
    Name John    Mckensy Valneech    Zeebra

    Try this,
    SELECT SYS_CONNECT_BY_PATH(ID,' '), SYS_CONNECT_BY_PATH(name, ' ') "Name"
    FROM testtable
    where level=(select count(*) from testtable)
    START WITH id=1
    coNNECT BY PRIOR id+1 = id;Rgds,
    Ahmer
    N.B.: To make a good reputation on forums, and if you want that your questions will be answered timely. Kindly adopt the habit of marking your questions closed as soon as you get the answer. and be courteous to the people who trying to help.

  • Looking for SQL to Display Rows as Columns in a View

    Hi!
    I am using Oracle 10g (10.1.0.4.0) 64 bit on Red Hat Enterprise Linux AS release 3.
    I have the following tables:
    Table A
    A_ID number (primary key)
    Table B
    B_ID number (primary key)
    B_NAME varchar2
    B_DESC varchar2
    Table C
    C_ID number (primary key)
    B_ID number (foreign key to table B)
    A_ID number (foreign key to table A)
    ORDERING number
    A row in table A can have from 0 (zero) to 3 (three) rows in table C associated with it.
    I am trying to make a view that displays A.A_ID and its associated rows from table C as a single row. For example, the following query:
    select A.A_ID, C.B_ID, B.B_NAME, B.B_DESC, C.ORDERING
      from C, B, A
    where C.A_ID = A.A_ID
       and C.B_ID = B.B_IDYields the following results:
    A_ID B_ID B_NAME B_DESC ORDERING
    100   10 A      One    1
    100   20 B      Two    2
    100   30 C      Three  3I would like to get the following:
    A_ID B_NAME_1 B_NAME_2 B_NAME_3
    100 A        B        CThanks (in advance :-),
    Avi.

    SQL> CREATE TABLE dt_test_a(a_id number)
      2  /
    Table created.
    SQL> CREATE TABLE dt_test_b(b_id number, b_name varchar2(1),b_desc varchar2(10))
      2  /
    Table created.
    SQL> CREATE TABLE dt_test_c(c_id number, b_id number, a_id number, ordering number)
      2  /
    Table created.
    SQL>
    SQL> insert into dt_test_a values(100)
      2  /
    1 row created.
    SQL> insert into dt_test_b values(10, 'A','One')
      2  /
    1 row created.
    SQL> insert into dt_test_b values(20, 'B','Two')
      2  /
    1 row created.
    SQL> insert into dt_test_b values(30, 'C','Three')
      2  /
    1 row created.
    SQL> insert into dt_test_c values(1, 10, 100, 1)
      2  /
    1 row created.
    SQL> insert into dt_test_c values(2, 20, 100, 2)
      2  /
    1 row created.
    SQL> insert into dt_test_c values(3, 30, 100, 3)
      2  /
    1 row created.
    SQL>
    SQL> SELECT
      2     a.a_id,
      3     DECODE(c.ordering, 1, b.b_name) b_name_1,
      4     DECODE(c.ordering, 2, b.b_name) b_name_2,
      5     DECODE(c.ordering, 3, b.b_name) b_name_3
      6  FROM
      7     dt_test_a a,
      8     dt_test_b b,
      9     dt_test_c c
    10  WHERE
    11     a.a_id = c.a_id
    12  AND
    13     b.b_id = c.b_id
    14  /
         A_ID B B B
          100 A
          100   B
          100     C
    SQL>
    SQL> SELECT
      2     a.a_id,
      3     MAX(DECODE(c.ordering, 1, b.b_name)) b_name_1,
      4     MAX(DECODE(c.ordering, 2, b.b_name)) b_name_2,
      5     MAX(DECODE(c.ordering, 3, b.b_name)) b_name_3
      6  FROM
      7     dt_test_a a,
      8     dt_test_b b,
      9     dt_test_c c
    10  WHERE
    11     a.a_id = c.a_id
    12  AND
    13     b.b_id = c.b_id
    14  GROUP BY
    15     a.a_id
    16  /
         A_ID B B B
          100 A B C
    SQL>
    SQL>
    SQL> insert into dt_test_a values(200)
      2  /
    1 row created.
    SQL> insert into dt_test_b values(40, 'A','One')
      2  /
    1 row created.
    SQL> insert into dt_test_b values(50, 'B','Two')
      2  /
    1 row created.
    SQL> insert into dt_test_b values(60, 'C','Three')
      2  /
    1 row created.
    SQL> insert into dt_test_c values(4, 40, 200, 3)
      2  /
    1 row created.
    SQL> insert into dt_test_c values(5, 50, 200, 2)
      2  /
    1 row created.
    SQL> insert into dt_test_c values(6, 60, 200, 1)
      2  /
    1 row created.
    SQL>
    SQL> SELECT
      2     a.a_id,
      3     MAX(DECODE(c.ordering, 1, b.b_name)) b_name_1,
      4     MAX(DECODE(c.ordering, 2, b.b_name)) b_name_2,
      5     MAX(DECODE(c.ordering, 3, b.b_name)) b_name_3
      6  FROM
      7     dt_test_a a,
      8     dt_test_b b,
      9     dt_test_c c
    10  WHERE
    11     a.a_id = c.a_id
    12  AND
    13     b.b_id = c.b_id
    14  GROUP BY
    15     a.a_id
    16  /
         A_ID B B B
          100 A B C
          200 C B A

  • IF NEW VARIABLE IN SQL QUERY, DISPLAYS AS LAST COLUMN + rpad not working

    Hello everybody and thank you in advance,
    1) if I add a new variable to my sql query to select a column which was already in the table, it shows it in the report table as the Last column to the right. That is, if I add "street" to
    something like city, postcode, street, store, manager, etc, instead of placing street between postcode and store, it places it as i said as the last column to the right.
    2) When values are entered into the cells of the tables, yes, they do expand it to their needed lenght, But, only if it is one word. If it is two, like when i enter the value "very good"
    then it takes two lines so as with a carriage return within the cell, thus, making it too high the row. I tried to padd spaces with rpad but it did not work. something like rpad(stock, 20,' ')
    I must say that the table is in the same page where there is a Form, so as the table grows in lenth it is actually squeezing the form located right on its left.
    3) rpad did not work with the most simple syntax, but less would with what i need because it turns out i am using DECODE in order to do a conversion between value displayed and
    value returned in my select list of values, something like : DECODE (TO_CHAR (stock),'1','Deficient','2','Average','3','Good','4','Very Good',null) AS stock,
    so, i have tried to put the rpad there in several places but either it gave parsing error or it left the column empty not picking any values.
    thank you very much
    Alvaro

    Alvaro
    1) That is standard behaviour of apex builder. You can change the display order with the arrows in the report attributes column report.
    2) You will have to play with the style attributes of the column to accomplice this. For instance style="white-space:pre;" in the Element Attributes of the column attributes. White-space:normal would thread several space (' ') as 1. So no matter how many you add with rpad they will be shown as 1.
    Or set a width either as attibute or in a style class for that column.
    Nicolette

  • Sql to display portlets on a page

    hi everybody,
    can someone give me the sql code to use in a query that will display a list of portlets associated with a particular page?
    thanks a bunch!

    Hi Swapna, and welcome!
    On the tree's SQL you can use two additional fields - A1 and A2 - to provide additional information. You can then amend the tree's template settings to position A1 and/or A2 wherever they are needed.
    Update your SQL statement to:
    SELECT ... ID,
    ... PID,
    ... NAME,
    ... LINK,
    COMMENTS A1,
    NULL A2
    FROM ...... is whatever your existing fields are and COMMENTS should be replaced by whatever field name contains the comments you want to display.
    Then, near the bottom of the tree definition, you will see two settings in a section headed "Node Text Templates". In both of these, you should see #A1# - this is the placeholder for the value in the A1 column. Remove these as they would just display as text on the page.
    Then, in the final section, headed "Link Templates", update the Name Link Anchor Tag from:
    &lt;a href="#LINK#"&gt;#NAME#&lt;/a&gt;to:
    &lt;a href="#LINK#" title="#A1#"&gt;#NAME#&lt;/a&gt;This puts your COMMENTS field value into the title attribute of the link - this is the "tooltip" for the item.
    click Apply Changes to save these.
    Andy

  • The output of sql loader displays '?' for the chinese character

    I'm run the sql loader to import the data. The following is the ctl script:
    LOAD DATA
    CHARACTERSET ZHS16CGB231280
    APPEND
    INTO TABLE xxabc_gti_feedback
    when (5:6) ='~~' and (8:9)='~~'
    FIELDS TERMINATED BY "~~"
    TRAILING NULLCOLS
    absoluted
    ,exist_lists
    ,invoice_type
    ,invoice_category_code
    ,invoice_number
    ,line_count
    ,invoice_date DATE "YYYYMMDD"
    ,invoice_month
    ,trx_number
    ,amount_without_tax
    ,tax_rate
    ,tax_amount
    ,gti_feedback_id "xxban_gti_feedback_s.nextval"
    ,creation_date sysdate
    ,last_update_date sysdate
    EBS version: R12(12.0.4)
    The characterset of database is UTF-8
    The file characterset is GB2312
    The following is the example of data file.
    SJJK0201~~已开发票传出
    39~~20110413~~20110413
    //发票1
    0~~0~~0~~325676740~~11085979~~3~~20110413~~04~~~~3336.71~~0.17~~567.24~~珠海XX机电设备有限公司~~440407897878~~珠海市香洲区XXX 0756-3666666~~建行前山支行777777~~XX电子(苏州)有限公司~~32170078678890~~苏州工业园区 6267565~~中国银行园区支行25456672~~1653\n31263\n67126~~XXX~~XXX~~XXX
    0~~aaa~~P83782~~个~~2~~6854.70~~0.17~~1165.30~~4010~~1~~1601
    1~~bbb~~~~~~~~-4065.00~~0.17~~-691.05~~~~1~~1601
    0~~ccc~~P80792~~个~~4~~547.01~~0.17~~92.99~~160~~1~~1601
    I create a sql*loader concurrent program to load the data. the data can be loaded into the table successfully(The chinese customer name is correct). Only for the aborted lines, it will be listed in the outtput of the concurrent request, but out of my expect, the chinese characters in the output are displayed as '?'.
    How to solve the issue? Thanks.
    Edited by: 852938 on 2011-4-17 下午10:41

    like the following:
    SJJK0201~~??????????
    39~~20110413~~20110413
    //???1
    0~~aaa~~P83782~~??~~2~~6854.70~~0.17~~1165.30~~4010~~1~~1601
    1~~bbb~~~~~~~~-4065.00~~0.17~~-691.05~~~~1~~1601
    0~~ccc~~P80792~~??~~4~~547.01~~0.17~~92.99~~160~~1~~1601
    You can find that any chinese characters are became '?'. The loaded line(Line 4th) is not listed in the output.
    Thanks for your quick answer! :)

  • SQL*Plus displays European chars incorrectly when using Net*8 to query remote DB

    I have two 8.1.5 DBs, one on Win2k and one on RedHat Linux 6.2. I can successfully insert and retreive Western European characters fine on each of those systems using SQL*Plus and Net*8, provided that I am connecting to the local DB. I can also insert these characters fine while using SQL*Plus and Net*8 between the systems.
    The failure shows up when I try to view (select) the Western European characters using SQL*Plus on the Win2k system while querying the data on the Linux system (via Net*8). What gets displayed is the 7-bit ASCII truncated-equivalent of the character. I have verified that the data is commited and can be viewed correctly when a query is issued from the Linux system.
    Has anyone encountered anything like this??
    Any advice would be appreciated.

    I am confused about your questions .
    I have two 8.1.5 DBs. I can successfully insert and retreive Western European characters fine on each of those systems using SQL*Plus and Net*8, provided that I am connecting to the local DB. What is local db ? Do you mean you need to use dblink to connect from one database to another ? Or do you mean local machines ?
    The failure shows up when I try to view (select) the Western European characters using SQL*Plus on the Win2k system while querying the data on the Linux system (via Net*8). Do you mean selecting data from the 8.1.5 DB on Linux from SQL*Plus on Win2K ?
    What are your db character sets ?
    What are your NLS_LANG enviroment settings ?
    Which datatypes are you using ? If NCHAR , what are your national database character sets ?

  • How to use SQL to display Datethat falls between the date range

    Hi,
    I'm figuring out how do i use SQL to select data
    that falls between the date range stated
    (for eg. 19/02/1955 to 19/02/2003)
    I've tried :
    sql="Select * From StudentRecords WHERE DOB BETWEEN #" jTextField21.getText() "#" +" And " +"#" +jTextField22.getText;
    Using BETWEEN statment , but Between Statement isn't doing what i want..
    even those out of range are displayed... any ideas how??
    Thank yOU in advance!

    oracle:
    sql = "Select * From StudentRecords WHERE DOB between TO_DATE('07/04/2003','dd/mm/yyyy') and TO_DATE('08/04/2003','dd/mm/yyyy')";

  • SQL Report Display Error when change LOVs In Report Attribute.

    Dear Friend,
    i have created SQL Report .Now In Agent Name Column ,Agent_code is Display .
    i want to display Agemt Name In to Agent_CODE Column so i have change in Report Attribute-->edit column AGENT_CODE-->Tabular Form Element-->Display As text (Based on LOV,Does not save state) -->List of Values -->Agent_name
    Apply Changes .
    Then it show me Below Error in Report
    report error:
    ORA-20001: Error fetching column value: ORA-06502: PL/SQL: numeric or value error: character string buffer too smallHow to resolve it?
    Thanks
    Edited by: Vedant on Sep 5, 2011 10:06 PM

    Dear Jari,
    yes i am not using Named LOV ,
    i am follow
    Report Attribute-->Tabular Form Element-->Display As text (Based on LOV,Does not save state) -->List of Values -->Agent_nameThen Show me Error.
    thanks
    Edited by: Vedant on Sep 6, 2011 1:37 AM

  • SQL Developer - displaying double byte (Japanese) characters

    I have installed SQL Developer on an English Windows XP system with Asian regional support installed.
    SQL Developer > preferences > database > set language, territory to Japan/Japanese.
    The strings are displaying as square boxes which means the characters are unable to display, I have verified on a Japanese machine that the characters to display with the same version of SQL Developer.
    Any ideas on how to get these characters to display?

    Hi user625396,
    Square boxes mean font not installed, for example on my Linux box for displaying Chinese:
    Chinese characters in linux see http://isis.poly.edu/~qiming/chinese-debian-mini-howto.html basically:
    1. create a jre/lib/fonts/fallback directory if necessary and
    2. copy or link the fonts files into this directory. (On my Linux system: /usr/share/fonts/truetype/arphic/gbsn00lp.ttf )
    3. I will install Japanese when the business need arises.
    Please confirm this fallback directory works for Japanese and Windows XP, with / changed to \ and the path to a Japanese font replacing /usr/share/fonts/truetype/arphic/gbsn00lp.ttf .
    I had a quick look for a windows XP/Japanese/fallback font page but I could not see one.
    -Turloch

  • SQL to display start, end date, days in each month between 2 dates

    HI all,
    Please hep since I'm so new on this. I have a date range 01/15/2012 to 11/26/2012. What I have to do is to display it like below:
    01/15/2012, 01/31/2012, 16 days
    02/01/2012, 02/29/2012, 29 days
    03/01/2012, 03/31/2012, 31 days
    11/01/2012, 11/26/2012, 26 days.
    Thanks for helping me.

    Hi Harvey,
    Try this....
    SELECT TO_DATE ('15-JAN-2012') start_date,
           LAST_DAY ((TO_DATE ('15-JAN-2012')))
                 end_date,
           (LAST_DAY ((TO_DATE ('15-JAN-2012'))) - TO_DATE ('15-JAN-2012')) no_of_days
      FROM DUAL
    UNION
    SELECT start_date, end_date, no_of_days
      FROM (SELECT     (TO_DATE ('15-JAN-2012') + LEVEL) start_date,
                       LAST_DAY ((TO_DATE ('15-JAN-2012')) + LEVEL)
                             end_date,
                       (  LAST_DAY ((TO_DATE ('15-JAN-2012')) + LEVEL)
                        + 1
                        - (TO_DATE ('15-JAN-2012') + LEVEL)
                       ) no_of_days
                  FROM DUAL
            CONNECT BY LEVEL <= (TO_DATE ('26-NOV-2012') - TO_DATE ('15-JAN-2012')))
    WHERE (   TO_CHAR (start_date, 'DD') = '01'
            OR start_date = TO_DATE ('15-JAN-2012')
            OR start_date = TO_DATE ('26-NOV-2012')
       AND start_date < TRUNC (TO_DATE ('26-NOV-2012'), 'MON')
    UNION
    SELECT TRUNC (TO_DATE ('26-NOV-2012'), 'MON') start_date,
           TO_DATE ('26-NOV-2012')
                 end_date,
           (TO_DATE ('26-NOV-2012') + 1 - TRUNC (TO_DATE ('26-NOV-2012'), 'MON')) no_of_days
      FROM DUAL;
    I Have hot coded the dates.. You can use parameters as start date and date
    Hope it will work.
    Regards,
    Soofi

Maybe you are looking for

  • No service for system sap*** client *** , sm58 error

    Hi Friends When I am trying to send message from My Xi system to R/3 system I am getting error., No service for system SAPSXD, client 001 in Integration Directory I had searched it on sdn n found that this is very common error. I had gone through blo

  • IWeb site redirects to MM mailbox or log-in

    I created a site with iWeb, but when I try to visit it, I get redirected to the MM log-in page or, worse, to my open mailbox. I can visit it fine on other computers. This happens with both Safari and Firefox. I've cleared the caches, history, etc. an

  • Color signatures not saved in Preview

    Hi all When I paste a signature into Preview (using the inbuilt Preview signature annotation) with a colored ink, it is fine on the screen, and also if printed to paper or pdf; but if the file is simply saved, upon reopening, the signature has change

  • Can't get anymore brightness out of Older 23" Apple Cinema HD Display

    Hey guys, So I'm trying to match an older monitor (Apple Cinema Display HD 23" circa 2002-04...I know) to a newer iMac. Currently attached using ADC->DVI->Thunderbolt. In comparison, the iMac is much brighter. I'm guessing due to the fact that it's n

  • One to many shuffle

    Hi Guys I want to know how do we save the data from one table to another as soon as the user shuffle the things in one to many shuffle this one to many shuffle is done based on selection of Radio group When user select a radio button as per that the