How to get first day of calendar week ?

hi,
i'm storing some calendar weeks in my database. for example 30/2013.
How can i get the first day of this week (monday)? in this case it is 22.07.2013
thx
Anja

As far as I know we don't have a function that converts week of a year into date. So you can try something like this.
SQL> with t
  2  as
  3  (
  4  select '30/2013' week_year
  5    from dual
  6  )
  7  select min(dt) week_start_day
  8    from (
  9           select (level - 1) + to_date('01-01-' || substr(week_year, -4), 'dd-mm-yyyy') dt
10                ,  week_year
11             from t
12          connect
13               by level <=  to_date('31-12-' || substr(week_year, -4), 'dd-mm-yyyy') -
14                            to_date('01-01-' || substr(week_year, -4), 'dd-mm-yyyy') +1
15         )
16   where to_number(to_char(dt, 'iw')) = to_number(substr(week_year, 1, instr(week_year, '/')-1));
WEEK_STAR
22-JUL-13

Similar Messages

  • From where to get "First day of the week" data for all the locales, is it present in CLDR spec 24?

    I am trying to get "First day of the week" data from CLDR spec24 but cannot find where to look for it in the spec. I need this data to calculate numeric value of "LOCAL day of the week".
    This data to implement "c" and "cc" day formats that equals numeric local day of the week.
    e.g if "First day of the week" data for a locale is 2 (Monday) , it means numeric value for local day of the week will be 1 if it is Monday that day, 2 if it is Tuesday that day and likewise.

    Hi
    If you want to week to be started with Sunday then use the following formula:
    TimestampAdd(SQL_TSI_DAY, 1-DAYOFWEEK(Date'@{var_Date}'), Date'@{var_Date}') if it's retail week(starts from Monday) then the follow below:
    TimestampAdd(SQL_TSI_DAY, 1-DAYOFWEEK(Date'@{var_Date}'), Date'@{var_Date}')
    I'm assuming var_Date is the presentation variable for prompt...
    Edited by: Kishore Guggilla on Jan 3, 2011 4:48 PM

  • How to set first day of the week?

    I'm trying to set up my iPad calendar so that my week view starts on Monday. My calendar on my desktop & MoblieMe starts the week on Monday which is what I want but my iPad starts on Sunday (even though it has been synced with my desktop & MoblieMe too). Please help! Thanks!

    Actually, I tried both UK and Australia, and Sunday was still the first day of the week.
    HOWEVER!!!
    Woohoo!!   American Samoa works, and doesn't seem to change any other formats (although admittedly I have not made an exhaustive search - just checked the International Example thing recommended by Matthias suggested.
    Matthias, thanks very much by the way!! 
    OZones

  • Get First day of a week

    Hi all,
    I have a question about using a presentation variable in a sql filter.Actually i have a presentation variable which return number of week per year ,the issue is that i want to have the firste day of the week selected in way to use it in the sql filter .
    Thanx for help

    Hi
    If you want to week to be started with Sunday then use the following formula:
    TimestampAdd(SQL_TSI_DAY, 1-DAYOFWEEK(Date'@{var_Date}'), Date'@{var_Date}') if it's retail week(starts from Monday) then the follow below:
    TimestampAdd(SQL_TSI_DAY, 1-DAYOFWEEK(Date'@{var_Date}'), Date'@{var_Date}')
    I'm assuming var_Date is the presentation variable for prompt...
    Edited by: Kishore Guggilla on Jan 3, 2011 4:48 PM

  • Getting first day of the week

    Dear All.
    As there is one function module BWSO_DATE_GET_FIRST_WEEKDAY which returns the first day of the week but its Monday but in our case we require Saturday and in some cases Monday.
    our user in UK are running the same report in which i have to calculate the stock base on starting day Monday and other uses are in KSA where the starting day of the week is Saturday.
    Is there any standard option available do achieve this.
    Kind regards,

    Hi Zeeshan,
    There are two options
    Option 1: In Routine or CMOD or in Variable use offset +5 or -2 according to your reporting requirements.
    Option 2: Maintain the table entries 52 Posting periods in T0009 or in custom table with special FISCAL Variant. (i.e., each week = one posting period). Have a loop up in that table according to your requirement.
    Hope either one of the option would help you in meeting your requirement.
    Best Wishes,
    BVC

  • How to get the day of 52 weeks ago data

    hi all:
    i recently encounter the difficulty that using the current data to get the 52 weeks ago data in essbase.the fct table is like this:
    current_dt the_day_of_week sales
    20110203 5dw05 100
    20100207 5dw05 30
    note: "5dw05" means the fifth day of five week in the selected year
    the question is which essbase formula to choise or how to use them in essbase outline structure can meet the bussines role that when the biz men chlic on the member "20110203" of time dimension, the extension mesure "bf_sales" value is 30.
    the outline i am about to design under the bellow:
    dim_time
    201002
    20110201(alias 4dw05)
    20110202(alias 5dw05)
    20110203(alias 6dw05)
    201102
    20110206(alias 4dw05)
    20110207(alias 5dw05)
    dim_measure
    sales
    bf_sales(will use the essbase formula,but do not know which function to choise or how to use it)
    i am lovely hope one of you may give me suggestion on this issue. thanks a lot for all of you!

    If you put the Apple calendar app on the first screen, it shows the day and date (no month/year). E.g Sunday 20.

  • How to get first day of the month by the given date?

    Now, is there function in CRM system that can get the first day of the month ?
    for example:
        input date is 2007/12/12, then return 2007/12/01 (the first day of month).
    Thank you~

    Hi ping,
    data: w_date type sy-datum ,
             w_temp(2) type c.
    w_date = '20071212'.
       w_temp = w_date+6(2).
       w_temp = w_temp - 1.
       w_date = w_date - w_temp.
    write / w_date.
    Plz Reward if useful,
    Mahi.

  • How to - get first DAY of the month from the date ?

    Hi
    pls help

    hi,
    data : DAYNR LIKE HRVSCHED-DAYNR,
    DAYTXT LIKE HRVSCHED-DAYTXT.
    data langu like sy-langu value 'EN'.
    Parameters PDATE LIKE SY-DATUM.
    PDATE+6(02) = '01'.
    CALL FUNCTION 'RH_GET_DATE_DAYNAME'
    EXPORTING
    LANGU = LANGU
    DATE = PDATE
    CALID =
    IMPORTING
    DAYNR = DAYNR
    DAYTXT = DAYTXT
    DAYFREE =
    EXCEPTIONS
    NO_LANGU = 1
    NO_DATE = 2
    NO_DAYTXT_FOR_LANGU = 3
    INVALID_DATE = 4
    OTHERS = 5
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    WRITE :/ PDATE, DAYNR, DAYTXT.
       (OR)
    Try..
    DATA:DAYNR  LIKE  HRVSCHED-DAYNR,
         DAYTXT LIKE  HRVSCHED-DAYTXT,
         DAYFREE LIKE  HRVSCHED-NODAY.
    DATA:LANGU LIKE  SY-LANGU ,
         DATE LIKE  SY-DATUM,
         CALID LIKE  P1027-CALID VALUE 'US'.
    date = sy-datum.
    date+6(2) = 01.           "----->to get the first day .
    *first day of the month
    write:/ 'First date of the month', date.
    *Day name
    CALL FUNCTION 'RH_GET_DATE_DAYNAME'
      EXPORTING
        langu                     = SY-LANGU
        date                      = DATE
        CALID                     = CALID
    IMPORTING
       DAYNR                     = DAYNR
       DAYTXT                    = DAYTXT
       DAYFREE                   = DAYFREE
    EXCEPTIONS
       NO_LANGU                  = 1
       NO_DATE                   = 2
       NO_DAYTXT_FOR_LANGU       = 3
       INVALID_DATE              = 4
       OTHERS                    = 5
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    WRITE:/ DAYTXT.
    Don't forget to reward if useful....

  • How do I change the first day of the week in calendar?

    I recently updated to ios 5.
    unfortunately, this made sunday day one of the week in calendar, not Monday which is my preference (and the convention in Australia).
    I was able to change it to Monday by changing international settings to UK, but this changed other settings such as uk version of google as default search engine, which I would prefer to avoid.
    Is there a way to make Monday the first day of the week in calendar AND keep my other international settings as Australia?
    Many thanks for suggestions.
    Chris.

    I don't think you can. Your best bet is to send Apple feedback and ask for that functionality.

  • How to get the First day in a Week in a Fiscal Year

    Hi guys,
    I have a Requirement to calculate the First day in  a Week  in a Fiscal year .
    The FM GET*FIRST_DATE and all are for Calender year.
    Is there any FM to calculate the First in a Week in a Fiscal year.
    For eg. They will give 200826.
    In this 26 is the Week.
    I need to find the First date value in that Week.
    Thanks,
    Gokul

    Hi Gokul...
    Instead of using the funtion module you can just write the 3 statements of code to get the first day of the week.
    Its similar to the above one but instead of writing case statement you can achive the following.
    data : w_res type i,
             w_data type d,
    w_res = w_date mod 7.
    w_date = w_date - w_res.
    write w_date.
    This works.
    Regards,
    Siddarth

  • Get date of first day of current week

    HI!
    Why does the following method do not return the date of the first day of the week in which the given date lies?
    public static int getFirstDayOfWeek(int year, int month, int date) { 
    GregorianCalendar GregCalendar = (GregorianCalendar)
    new GregorianCalendar(year, month, date).getInstance();
    while(GregCalendar.get(Calendar.DAY_OF_WEEK)!= Calendar.MONDAY) {
    GregCalendar.roll(Calendar.DATE, false);
    return GregCalendar.get(Calendar.DATE);     
    What I want the method to do:
    year = 2003
    month = Calendar.JANUARY
    date = 8
    ==> GregCalendar.get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY
    ==> GregCalendar.roll(Calendar.DATE, false);
    ==> GregCalendar.get(Calendar.DATE) == 7 (?????????)
    ==> GregCalendar.get(Calendar.DAY_OF_WEEK) == Calendar.TUESDAY
    ==> GregCalendar.roll(Calendar.DATE, false);
    ==> GregCalendar.get(Calendar.DATE) == 6
    ==> GregCalendar.get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY
    ==> return GregCalendar.get(Calendar.DATE)
    But in reality, it always returns 6 grrrrrrrr
    What is wrong wirh it?
    Yours RB

    public Date getCurrentMonday()
            Date monday = null;
            Calendar rightNow = Calendar.getInstance();
            int day = rightNow.get(Calendar.DAY_OF_WEEK);
            int distance = 0;
            if (day == Calendar.MONDAY)
                monday = rightNow.getTime();
            else
                distance = day - Calendar.MONDAY;
                if (distance == -1)
                    distance = 6;
                monday = (Date) (rightNow.getTime());
                monday.setTime(monday.getTime() - 1000 * 60 * 60 * 24 * (distance));
            return monday;
        }

  • Changing the calendar settings: Sunday as the first day of the week

    Dear Masters of SAP universe,
    In ECC6.0, I am using a LIS info-structure with the period split set to week.
    I would like to know how can I change the calendar settings in order to consider Sunday as the first day of the week, instead of Monday.
    For example:
    A sales order created on Dec 12th creates the record 201049 in the info structure S900 - SPWOC.
    I would like to have it as 201050, where 50 is the currently week in the system.
    I already checked OSS notes and the transaction SCAL for customizing. But I did not find a solution this issue.
    Your help is highly appreciated!

    hi,
    this seems to be a calendar issue.
    please check for OSS also - 1158474.
    balajia

  • Want to make Monday as the first day of the week in GregorianCalendar. how?

    hi
    I need to know what day is the first of the month is. for example the 1st of Nov 2004 is Moday and 1st of Dec 2004 is saturday.
    I am using the GregorianCalendar:
    1.  GregorianCalendar calendar = new GregorianCalendar(2004,11,1);    //set date to 1st Nov 2004
    2.  int firstDay = calendar.get(Calendar.DAY_OF_WEEK);now firstDay is 2. This is because the week starts from Sunday, so Monday is the 2nd day.
    But I am in Uk and my Uk Calendar shows monday as the first day (even in Windows 2000 Calendar).
    I would like the GregorianCalendar to have Monday as the first day of the week, so that the
    int firstDay = calendar.get(Calendar.DAY_OF_WEEK);
    returns 1 in the above case.
    I also tried adding
    calendar.setFirstDayOfWeek(Calendar.MONDAY); just between line 1 and line 2, but it did not help.
    This is because i don't want to manually subtract 1. If i manually subtract one, then the program might not work in other locale and timezones.
    Also if I subtract 1, then for 1 Feb 2004,
    int firstDay = calendar.get(Calendar.DAY_OF_WEEK);
    will return 1 as 1st Feb 2004 falls on Sunday. so if i subtract 1 it will be 0, so I have to do a extra checking for 0.
    Is there anyway to make the Calendar have Monday as the first day of the week??
    Tanveer

    hi
    I need to know what day is the first of the month is.Why does this matter? Since we know that 1 == Sunday and 2 == Monday... Why do you need Monday to be == 1? and couldn't you just subtract 1 if it's so important?
    for example the 1st of Nov 2004 is Moday and 1st of
    Dec 2004 is saturday.
    I am using the GregorianCalendar:
    1.  GregorianCalendar calendar = new
    GregorianCalendar(2004,11,1);    //set date to 1st Nov
    2004
    2.  int firstDay = calendar.get(Calendar.DAY_OF_WEEK);now firstDay is 2. This is because the week starts
    from Sunday, so Monday is the 2nd day.
    But I am in Uk and my Uk Calendar shows monday as the
    first day (even in Windows 2000 Calendar).
    I would like the GregorianCalendar to have Monday as
    the first day of the week, so that the
    int firstDay = calendar.get(Calendar.DAY_OF_WEEK);
    returns 1 in the above case.
    I also tried adding
    calendar.setFirstDayOfWeek(Calendar.MONDAY);[/cod
    ] just between line 1 and line 2, but it did not help.
    This is because i don't want to manually subtract 1.
    If i manually subtract one, then the program might not
    work in other locale and timezones.
    Also if I subtract 1, then for 1 Feb 2004,
    int firstDay = calendar.get(Calendar.DAY_OF_WEEK);
    will return 1 as 1st Feb 2004 falls on Sunday. so if i
    subtract 1 it will be 0, so I have to do a extra
    checking for 0.
    Is there anyway to make the Calendar have Monday as
    the first day of the week??
    Tanveer

  • Change first day of the week in Calendar?

    When I updated my iPhone to 3.0, my default Calendar app switched the first day of the week (in month view mode) from Sunday to Monday. Any idea how I can change this back?
    -Gerald

    What application does your iPhone calendar sync with on your computer? I have had all three versions of the iPhone and can't remember any of them showing Monday as the first day of the week in "Month" view. Of course that doesn't mean anything... can you post a picture showing Monday as the first day of the week?
    Message was edited by: dmiannay

  • First day of the week in calendar

    In the UK (as in many countries) the week starts on Sunday and calendars normally reflect this. With iPhone the week starts on Monday (in UK) but in Ireland it starts on Sunday. I really can't use a calendar showing Monday as the first day of the week (it's too confusing when compared to printed calendars and iCal on the computer). If I set iPhone calendar to Ireland that's fine for a while but soon it reverts to UK and Monday. Is it possible to make this calendar show the correct day all the time?

    Yes, it's possible, by changing Settings > General > International > Region Format to something other than the UK. Setting it to the United States will give you a week starting on Sunday. But, that setting also controls the way dates and phone numbers are displayed, so those are affected as well. But, maybe that's already how you already "set iPhone calendar to Ireland," in which case, I'm not sure why it's reverting back, unless it's resulting from when you sync the phone to your computer.

Maybe you are looking for