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

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 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

  • 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

  • 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;
        }

  • 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

  • Function Modules to get First day of week, month, Year

    Can anyone name the Function Modules for getting First day of week, month ,year.

    to get first day of week use this function;   WEEK_GET_FIRST_DAY
          CALL FUNCTION 'WEEK_GET_FIRST_DAY'
               EXPORTING
                    WEEK         = '201107'
               IMPORTING
                    DATE         = l_date
               EXCEPTIONS
                    WEEK_INVALID = 1
                    OTHERS       = 2.
    with DATE_COMPUTE_DAY function you can get date number in week.
    CALL FUNCTION 'DATE_COMPUTE_DAY'
           EXPORTING
                DATE = workdate
           IMPORTING
                DAY  = day_of_week_num
           EXCEPTIONS
                OTHERS  = 8.
      CASE day_of_week_num.
        WHEN 1.
          hold_day_of_week = 'Monday'.
        WHEN 2.
          hold_day_of_week = 'Tuesday'.
        WHEN 3.
          hold_day_of_week = 'Wednesday'.
        WHEN 4.
          hold_day_of_week = 'Thursday'.
        WHEN 5.
          hold_day_of_week = 'Friday'.
        WHEN 6.
          hold_day_of_week = 'Saturday'.
        WHEN 7.
          hold_day_of_week = 'Sunday'.
        WHEN OTHERS.
          hold_day_of_week = 'invalid'.
      ENDCASE.

  • Setting the first day of the week

    Hi,
    Is there any other place in Mac OS X where I could set system's first day of the week, except iCal? In iCal it's set to Sunday, but in OmniFocus mini calendars show Monday as the first day of the week, although even there in OmniFocus preferences I've set it to use Sunday as the first day of the week. Developer says that OmniFocus is using system's settings, but nowhere in my system (except iCal) I can find where I could set the first day of the week. I have set English as the default language and order of list sorting in the International settings. Any ideas or suggestions?

    Unless it is set with the Country in the International preferences, I don't think their tech support knows what they are talking about. However, if that is where it would be set, you should be able to override it with the custom settings, but you can't.
    I'd ask them to tell you where that gets set, or is stored. Ask them what system call is used to get that value. My guess is they won't be able to tell you.

  • 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

  • Date field input help - changing first day of the week

    Hi,
    I need to change the starting day of the week  in a date field value help. I also need to change the days name in this calender.
    Thanks in Advance,
    Dekel.

    I found how to change the first day of the week, through BAdi calendar_definition.
    Can anyone help me locate the day names? (I checked - FM day_names_get dosen't get the names of the UI search help).
    Thanks,
    Dekel.
    Edited by: dekel31 on May 29, 2011 1:17 PM

  • Moving a GregorianCalendar to the first day of the week

    I'm using a GregorianCalendar class in order to get the time stamp for the nearest Sunday's date.
    here's what I'm trying to do:
    1. get a timeStamp and set it into a date
    Date startDate = new Date(startTime);2. create a new GregorianCalendar using the above date as the start time.
    GregorianCalendar calendar = new GregorianCalendar((startDate.getYear()+1900),startDate.getMonth(),startDate.getDate());3. the tricky part: make sure the calnedar's date is set to Sunday, if the current date is on any day other then Sunday, I will have to move it back to the nearest Sunday. I'm trying to do this by using:
    calendar.set(Calendar.DAY_OF_WEEK, 0);     for some reason this does not work...
    am I doing anything wrong here?

    thanks for that info but the problem is still there. here's some more input:
    //creating the date, the ts here is 1153858800000 which is the dated in 7/25/2006
    Date startDate = new Date(startTime);
    //creating the new calendar
    GregorianCalendar calendar = new GregorianCalendar((startDate.getYear()+1900),startDate.getMonth(),startDate.getDate());
    //setting the calendar to the first hour (not sure it necessary)
    calendar.set(Calendar.HOUR, 1);
    //setting the calendar to the first day of the week
    calendar.set(Calendar.DAY_OF_WEEK, 1);
    //this returns 1153778400000 which is still dated 7/25/2006 whic is a Tuesday I would expect it to returns a different date
    calendar.getTimeInMillis()     

  • Function module for getting starting day of a week form current data

    Hi ,
    Is there any function module that gives starting day of week when we give a particular date
    eg: today date is 19-12-2007
    if i give this date as input i should get 16-12-2007 because this is starting day of this week .

    Hi,
    Use FM  GET_WEEK_INFO_BASED_ON_DATE
    You will get the first day of the week in export parameter MONDAY
    Lokesh

  • First day of the week issue

    Hello everyone,
    We have recently setup workforce management in our environment.  The person that set it up initially set it up so that the first day of the week for the schedule is sunday.  I would like to change this to monday, so that the schedule is monday thru sunday so it can coinside with payroll.  But when i do this and rerun a schedule request it comes up blank.  I feel like im missing something but i dont know what.  Any help would be greatly appreciated.

    There really is no screenshot to post.  I don't get any error message.  I just get nothing, no empoyees show up in the Schedule
    Viewer.  It says there is no schedule for this period.  When i change the day back to start on sunday and rerun the schedule request everything comes up fine.

  • HT2513 Changing First Day of the week shown in week view in iCal

    How do you change the week view of iCal from Sun to Mon. I have done it beofre ios 6. How does one do this since ios 6?
    I have iCal on iMac as Monday as first day showing in week view but I also want it to show on iPad the same way.
    Any information on this would be great.

    Bump

  • 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

Maybe you are looking for