How to get the last day of the week?

HII

I can get the week number of calendar for a given date using

SELECT to_char (to_date('04/04/2011','MM/DD/YYYY'), 'WW') FROM dual

can any body tell me, how to get the last day of the week?

and the answer should be: 04/08/2011(8th april)
Thank you
San

Published by: sandeep9 on April 4, 2011 03:50

Perhaps this...

SQL> select trunc(sysdate,'WW')+6 from dual;

TRUNC(SYSDATE,'WW')+
--------------------
08-APR-2011 00:00:00

SQL>

Tags: Database

Similar Questions

  • How to get sales last day of the previous month

    HELO guys

    I have a question how do I get sales date last day of the previous month where my fact table is level. in fact I tried using Ago but it seems not working. for example, if I chose December 29, 2014 so if I used the function there are then the result will display data on November 29, 2014 (not the last day of November 2014).

    Please guys if you have any solution and I really advise thanks to you.

    Not exactly under what circumstances specific as you try to reach this goal, but suppose you have a few guest dashboard where you select a day and you have a report with a measure where you want to show the sales of the last day of the previous month based on the selected date in the dash prompt.

    If you change the formula of this measure to something like:

    FILTER (with the HELP of 'Sales' (DATE = TIMESTAMPADD (SQL_TSI_DAY-1, TIMESTAMPADD (SQL_TSI_DAY, DAYOFMONTH(@{PV_DATE_SELECTED}) * (-1) + 1, @{PV_DATE_SELECTED}))))

  • How to get the week sequence?

    Hi friends,

    Greetings of the day!

    I am greatly in dealing with the next thing.

    I have two tables. a table with all the required information and another table called process_dtl, have the details of refreshment. These tables gets updated once a week. when its gets refreshed have will update the process_dtl table start date and refreshes the end date. There are also a few unique seq_no for each update. I will combine these 2 tables with seq_no process, because it is the unique key in the two tables. About these tables are more 2-year data. But what I want, I want only 6 months given. With 6 months data, based on the start_date I want to have the data week sequence. Means I want to know if it is given 1 week or 2 weeks, etc because the data get updated once a week. Is it possible to distinguish like this using start date. Please reply back if you understand the above.
    I'm using oracle 11g.


    Thank you

    Published by: 981145 on May 8, 2013 04:56

    You can get the data from the last 6 months simply by using the WHERE clause to limit the process_start_dt or process_end_date, as mentioned by Chris above. Since the sequence of steps. is unique for each race, I assume that the data you get from dtap_rpt_site_dtl_hst for that sequence number. needs no other filter criteria, so it must be good there.

    For the format of the week like you wanted, use the following in your select clause-

    to_char(process_start_dt, 'Mon') ||' ' || to_char(process_start_dt, 'D') week_seq
    

    Hope this has helped.
    Thank you!

  • How to get the week of the year in American Standard

    Hello

    I know that it might be a repetitive question, but has not found a convincing solution to him in any of the previous threads. I'm looking for a function (user defined, if someone has already written it) go the week of the year, American Standard. i.e., The week should begin on Sunday and end on Saturday (and NOT from Monday to Sunday)

    03/01/2010 - should be the beginning of the 1st week of 2010... 10/01/2010 will be the beginning of the second week and so on
    04/01/2009 - should be the beginning of the 1st week of 2009... 11/01/2009 will be the beginning of the second week and so on.

    Does anyone have a function that takes a date as input and returns back the week of the year in the above format? Any help is greatly appreciated.

    Thank you

    You can add a day to your date in order to manipulate the weeks;

    with t as (
       select to_date('02/01/2010','dd/mm/yyyy') dt from dual union all
       select to_date('03/01/2010','dd/mm/yyyy') from dual union all
       select to_date('09/01/2010','dd/mm/yyyy') from dual union all
       select to_date('10/01/2010','dd/mm/yyyy') from dual)
    select dt, to_char(dt, 'Day') dy, to_char(dt+1, 'iw') wk
    from t;
    
    DT          DY        WK
    ----------- --------- --
    02/01/2010  Saturday  53
    03/01/2010  Sunday    01
    09/01/2010  Saturday  01
    10/01/2010  Sunday    02
    
  • How to get the week of the current month

    Hi all
    Is it possible to find the week of the current month.

    Help, please...

    Hello...

    Use this feature to get the desired result.

    Hope it's okay...

    CEILING (DAYOFMONTH ("Time D0". "T00 calendar date") (/ 7.00) "

    Note: use 7.00 7 not only in the denominator*.

  • How to get the last date of 3 days for the current month?

    Hello. Guy

    How to get the last date of 3 days for the current month?

    MY OUTPUT WOULD LOOK LIKE THIS

    JANUARY 29, 2016

    JANUARY 30, 2016

    JANUARY 31, 2016


    GUYS HELP ME / / /...

    SQL > select last_day (sysdate) - level + 1 double connect by level<= 3="" order="" by="">

    LAST_DAY)

    ---------

    29 JANUARY 16

    30 JANUARY 16

    31 JANUARY 16

  • How to get the last day of a month for every 2 months for a given period?

    Hello

    Can is it some please let me know how to get the last day, last day of the week, the weekend last day, last Monday, one month for every 2 months for a given period?

    Thanks in advance.

    Try the below

    SELECT LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2))) lastday.

    BOX WHEN TO_CHAR (LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2))), 'DY') = 'SAT '.

    SO LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2)))-1

    WHERE TO_CHAR (LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2))), 'DY') = 'Sun '.

    THEN LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2)))-2

    Of OTHER LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2)))

    END as lastweekday,

    BOX WHEN TO_CHAR (LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2))), 'DY') IN ('Sam', 'SUN')

    THEN LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2)))

    Of OTHER LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2)))

    -(TO_NUMBER (TO_CHAR (LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2))),' from)) - 1).

    END as lastweekendday,

    BOX WHEN TO_CHAR (LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2))), 'DY') = 'MY

    THEN LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2)))

    Of OTHER NEXT_DAY (LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2))), "LUN")-7

    END AS lastmonday

    FROM (SELECT SYSDATE startdate,

    SYSDATE + 300 enddate

    THE DOUBLE)

    CONNECT BY LEVEL<=>

  • How to get the maximum number of days in a month?

    How to get the maximum number of days in a month?

    I use a dateField. where I can get the month. Now, I want to get the maximum number of days in a month.

    How can I get it?

    Please help me. and thanks in advance... []

    NET. RIM. Device.API.util
    Class DateTimeUtilities

    getNumberOfDaysInMonth (int month, int year)
    Returns the number of days in the specified month

    It took me like 10 seconds to find it in the API, I guess you spent more time writing the post...

  • How to get the last access to the workflow? (OM, WMS) release 11.5.9

    Hello my friends.

    I am looking for information on how to get the date of the access and the user name who did use some WFs in OM and last WMS.

    If it is through the application or running in the background via SQL for the information is not important to me.

    Could you help me with this?.

    Thank you

    the 'item_type' attribute must match the name of the WF?

    Yes (internal name. For example OEOL).

    The custom of those who will not be affected by the upgrade.

    You must run the query that I provided before to identify if the workflow is used or not.

    For the workflow of order lines, it is intended to be used as you use the order management.

    Kind regards

    Bashar

  • How to get the 'DAY' based on the territory of current account held a number between

    Hi all

    Looks like I'm at the end of my intelligence here but how to get the 'DAY' based on the territory of current account with a number between 1 and 7? Oracle has functions to extract the day of the week, but I can't find the other way around.
    SQL> select * from v$version;
    
    BANNER
    --------------------------------------------------------------------------------
    Oracle Database 11g Release 11.2.0.3.0 - 64bit Production
    PL/SQL Release 11.2.0.3.0 - Production
    CORE    11.2.0.3.0      Production
    TNS for Linux: Version 11.2.0.3.0 - Production
    NLSRTL Version 11.2.0.3.0 - Production
    
    SQL> alter session set nls_territory=AMERICA;
    
    Session altered.
    
    SQL> select to_char (sysdate, 'D') from dual;
    
    T
    -
    3
    
    SQL> alter session set nls_territory=GERMANY;
    
    Session altered.
    
    SQL> select to_char (sysdate, 'D') from dual;
    
    T
    -
    2
    I need a way to know that the number '3' on the database with NLS_TERRITORY = AMERICA means a 'Tuesday' or the number '2' on a database with NLS_TERRITORY = GERMANY means "Tuesday" as well.

    Hope I am clear enough.

    And wish you all a happy new year :)

    Kind regards
    Smail

    Use the format "IW" to get the date of Monday and the format "DAY" to get the "first day of the week. Then compare dates to see if they are identical.

    ALTER SESSION SET NLS_TERRITORY = 'AMERICA';
    
    SELECT TRUNC(SYSDATE-LEVEL, 'IW') "Monday",
    TRUNC(SYSDATE-LEVEL, 'DAY') "NLS First day of week",
    MOD(TRUNC(SYSDATE-LEVEL, 'IW') - TRUNC(SYSDATE-LEVEL, 'DAY') + 7, 7) "1 if day 1 = SUN, 0 if MON"
    FROM DUAL CONNECT BY LEVEL <= 7;
    
    Monday    NLS First day of week 1 if day 1 = SUN, 0 if MON
    --------- --------------------- --------------------------
    31-DEC-12 30-DEC-12                                      1
    24-DEC-12 30-DEC-12                                      1
    24-DEC-12 23-DEC-12                                      1
    24-DEC-12 23-DEC-12                                      1
    24-DEC-12 23-DEC-12                                      1
    24-DEC-12 23-DEC-12                                      1
    24-DEC-12 23-DEC-12                                      1
    
    alter session set nls_territory = 'FRANCE';
    
    SELECT TRUNC(SYSDATE-LEVEL, 'IW') "Monday",
    TRUNC(SYSDATE-LEVEL, 'DAY') "NLS First day of week",
    MOD(TRUNC(SYSDATE-LEVEL, 'IW') - TRUNC(SYSDATE-LEVEL, 'DAY') + 7, 7) "1 if day 1 = SUN, 0 if MON"
    FROM DUAL CONNECT BY LEVEL <= 7;
    
    Monday   NLS First day of week 1 if day 1 = SUN, 0 if MON
    -------- --------------------- --------------------------
    31/12/12 31/12/12                                       0
    24/12/12 24/12/12                                       0
    24/12/12 24/12/12                                       0
    24/12/12 24/12/12                                       0
    24/12/12 24/12/12                                       0
    24/12/12 24/12/12                                       0
    24/12/12 24/12/12                                       0
    

    Or it could be simpler:

    ALTER SESSION SET NLS_TERRITORY = 'AMERICA';
    
    WITH DATA AS (SELECT LEVEL INPUT_DAY FROM DUAL CONNECT BY LEVEL <= 7)
    SELECT INPUT_DAY,
    TO_CHAR(TRUNC(SYSDATE, 'Day')+INPUT_DAY-1, 'DAY') "Day label"
    from data;
    
    INPUT_DAY Day label
    --------- ------------------------------------
            1 SUNDAY
            2 MONDAY
            3 TUESDAY
            4 WEDNESDAY
            5 THURSDAY
            6 FRIDAY
            7 SATURDAY
    
    alter session set nls_territory = 'FRANCE';
    
    WITH DATA AS (SELECT LEVEL INPUT_DAY FROM DUAL CONNECT BY LEVEL <= 7)
    SELECT INPUT_DAY,
    TO_CHAR(TRUNC(SYSDATE, 'Day')+INPUT_DAY-1, 'DAY') "Day label"
    from data;
    
    INPUT_DAY Day label
    --------- ------------------------------------
            1 MONDAY
            2 TUESDAY
            3 WEDNESDAY
            4 THURSDAY
            5 FRIDAY
            6 SATURDAY
            7 SUNDAY
    
  • 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.

  • How to get the date in the exact day in the field when another?

    Hello

    Please help me how to get the day of the week using another date field.

    In fact, a field (week_day) has 1,2,3,4,5,6,7 here 1-, 2 - KILL like this.
    another field has the date. After this date, go to this particular week and need to pick up the date of the Etiquettemois above. It should be this week there himself.

    Thanks in advance!

    Kind regards
    Florian...

    Published by: Florian on October 29, 2010 03:07

    Maybe it's

    select trunc(date_field,'D') + week_field - 1 from table
    
  • How to get the video intro off my google home screen I already saw it, where is the firefox logo used to be.

    How to get the video intro off my google home screen I already saw it, where is the firefox logo used to be. I started with the last update that I rebooted.

    Hello
    to change the homepage when opening firefox-press 'Alt' and click on tools-> Options.

    Main menu, you can change the URL.

    If the problem persists, you can follow these simple steps:

    Enter about: config in the address bar and press ENTER. Accept the message of 'dragons' to see the Advanced preferences screen. Use the above search box to enter the below pref.

    You can assign an empty string to stop your Firefox to retrieve "extracts" and brandLogo changes the browser.aboutHomeSnippets.updateUrl pref. Right-click this pref and select Edit then clear the value as pref in the box that appears, and then click OK. Who will also disable "snippets" that appear under the container of the research on the default home page.

    Then you must open the folder of your profile, via help > Troubleshooting Information > profile folder > > button view folder. Then close Firefox. Your profile file open with Firefox closed (Firefox '3-bar' menu key > exit/Quit), wait or two minutes, then remove the storage\moz-safe-about + home folder in the Firefox profile folder to remove the brandLogo and stored in IndexedDB code snippets to make Firefox use the default brandLogo and a defined default code snippet.

    If you later change your mind about these changes, you can reset the pref browser.aboutHomeSnippets.updateUrl via the context menu and Reset allows to retrieve the default value using the storage\moz-chest-fort-about + home folder again.

  • How to get the Date, month, year of the DateTimePicker

    Hi, I am using the DateTimePicker.

    There are several question about this command:

    1. how to get the Date, month and year?

    -With the help of myDateTime.value, I get this string ' Wed May 08 14:45 ICT 2013 '-> I have to manually analyze this? Because I need in format yyyy/mm/dd. Or can set the format of dateTimePicker.value?

    2 format on dateTimePicker self (on the user interface) is d/m/YY, I can't change to another format?

    Thank you

    dateTimePicker.value return a QDateTime not a string.

    https://developer.BlackBerry.com/Cascades/reference/bb__cascades__datetimepicker.html#property-value

    See more:

    https://developer.BlackBerry.com/Cascades/reference/QDateTime.html#date

    https://developer.BlackBerry.com/Cascades/reference/QDate.html

    You can get

    day = dateTimePicker.value.date().day()
    month = dateTimePicker.value.date().month()
    year= dateTimePicker.value.date().year()
    dateYYYYMMDD = dateTimePicker.value.date().toString(Qt::ISODate)
    dateYYYYMMDD2 = dateTimePicker.value.date().toString("YYYY/MM/DD")
    dateYYYYMMDD3 = dateTimePicker.value.toString("YYYY/MM/DD")
    
  • How to get the current timestamp in C++ to the BB10 project

    Please help me how to get the current timestamp in C++. Thanks for your help!

    Following your suggestion,

    QTime is only for a day.  http://developer.BlackBerry.com/Cascades/reference/QTime.html#details

    I found "QDateTime" of references of the API: http://developer.blackberry.com/cascades/reference/qdatetime.html#toTime_t

    QDateTime = now QDateTime::currentDateTime();
    timestamp long = now.toTime_t ();

    But I got an error. I searched but no results are clear:

    -variable 'QDateTime now' initializer has but
    incomplete type
    -type incomplete "QDateTime" used in the nested name
    specifier of

    I am a newbie. So thank you for your help

Maybe you are looking for

  • Update of KitKat 4.4.2 on HP Slate6 voice tab

    Hello! This morning, I had a system update on my HP Slate6 voice tab for android KitKat 4.4.2. After downloading, it required a reboot of the system. However, restarting, the following image appeared on the screen: I tried to do a factory reset, but

  • Satellite P200 - Microphone has stopped working after installing Windows 7

    My Satellite P200 came with Vista Ultimate, the mic has worked for a few months, all of a sudden it stopped. I decided to install Windows 7, but the microphone still does not work.Any ideas anyone? I use this laptop for skpe my people a lot. I can us

  • How to know the version of WRVS4400N

    How will I know if I have a V1 or V2.  I bought what was advertised as a WRVS4400N V2, but the firmware shows that V1.  Given that the firmware was a V1 I only applied the update of the firmware V1.1.13.  Can I use the update of the firmware V2 on th

  • BlackBerry® Smartphones email most recent on top

    Every time when I check my email, I need to scroll down to get to my most recent email. Is there any setting so the cursor starts on top with the most recent email first?

  • Error message decode Help Needed

    I get the error message following two devices on my network: CRYPTO-4-RECVD_PKT_MAC_ERR: decrypt: mac check failed for the login id = local = remote spi F1E30F16 seqno = D 0000905 = = Cisco decodes the message as: % CRYPTO-4-RECVD_PKT_MAC_ERR: decryp