Function module to retrieve day of the week from a date.

Hi Experts,
i am looking for a function module to retrieve the day of the week from a specific date. For example, the date is 20070820. The day of this date is 'Monday'.
Please let me know how do i get the result i.e. 'Monday'.
thanks a lot for ur timely help.
Best regards,
Aksh

DATE_COMPUTE_DAY
     Returns a number indicating what day of the week the date falls on. Monday is returned as a 1, Tuesday as 2, etc.
DATE_IN_FUTURE
     Returns a number indicating what day of the week the date falls on. Monday is returned as a 1, Tuesday as 2, etc.
DAY_ATTRIBUTES_GET
     Return useful information about a day. Will tell you the day of the week as a word (Tuesday), the day of the week (2 would be Tuedsay), whether the day is a holiday, and more
regards,
srinivas

Similar Messages

  • Find first & last day of the week from given date

    Hi All,
    I have the below input query,
    WITH TEM AS   ( SELECT '11-JAN-13' DT from dual union   SELECT '16-JUN-12' from dual union   SELECT '04-JUL-12' from dual union   SELECT '09-JAN-13' from dual union   SELECT '10-JAN-13' from dual union   SELECT '04-JAN-13' from dual union   SELECT '07-JAN-13' from dual union   SELECT '04-JUN-13' from dual union   SELECT '08-JAN-13' from dual )  SELECT TO_DATE(DT) D1,'WEEK '||TO_CHAR(TO_DATE(DT),'IW-YYYY') WK from tem;
    I would like to get the below output i.e. Starting date of the week(Saturday) & end date of the week(Friday)
    DT
    WEEK Period
    Max Date in this week
    Min Date in this week
    16-Jun-12
    WEEK 24-2012
    16-Jun-12
    22-Jun-12
    04-Jul-12
    WEEK 27-2012
    30-Jun-12
    06-Jul-12
    04-Jan-13
    WEEK 01-2013
    04-Jan-13
    29-Dec-12
    07-Jan-13
    WEEK 02-2013
    05-Jan-13
    11-Jan-13
    08-Jan-13
    WEEK 02-2013
    05-Jan-13
    11-Jan-13
    09-Jan-13
    WEEK 02-2013
    05-Jan-13
    11-Jan-13
    10-Jan-13
    WEEK 02-2013
    05-Jan-13
    11-Jan-13
    11-Jan-13
    WEEK 02-2013
    05-Jan-13
    11-Jan-13
    04-Jun-13
    WEEK 23-2013
    01-Jun-13
    07-Jun-13
    Also suggest if any function available in oracle for this one.

    Like this? I think in your required output, 3rd row data, MAX_DATE should be 29-DEC-12 and MIN_DATE should be 04-JAN-13.
    WITH TEM AS 
    ( SELECT '11-JAN-13' DT from dual union 
    SELECT '16-JUN-12' from dual union
    SELECT '04-JUL-12' from dual union
    SELECT '09-JAN-13' from dual union
    SELECT '10-JAN-13' from dual union 
    SELECT '04-JAN-13' from dual union
    SELECT '07-JAN-13' from dual union
    SELECT '04-JUN-13' from dual union
    SELECT '08-JAN-13' from dual )
    SELECT D1 DT,
           WK WEEK_PERIOD,
           CASE WHEN (TRIM(TO_CHAR(D1,'DAY'))='SATURDAY') THEN D1
                 ELSE NEXT_DAY(D1,'SATURDAY')-7
            END AS MAX_DATE_IN_THIS_WEEK,
          CASE WHEN (TRIM(TO_CHAR(D1,'DAY'))='FRIDAY') THEN D1
                ELSE NEXT_DAY(D1,'FRIDAY') END AS MIN_DATE_IN_THIS_WEEK
    FROM (
    SELECT TO_DATE(DT) D1,'WEEK '||TO_CHAR(TO_DATE(DT),'IW-YYYY') WK from tem)
    ORDER BY DT;
    OUTPUT:
    DT        WEEK_PERIOD  MAX_DATE_ MIN_DATE_
    16-JUN-12 WEEK 24-2012 16-JUN-12 22-JUN-12
    04-JUL-12 WEEK 27-2012 30-JUN-12 06-JUL-12
    04-JAN-13 WEEK 01-2013 29-DEC-12 04-JAN-13
    07-JAN-13 WEEK 02-2013 05-JAN-13 11-JAN-13
    08-JAN-13 WEEK 02-2013 05-JAN-13 11-JAN-13
    09-JAN-13 WEEK 02-2013 05-JAN-13 11-JAN-13
    10-JAN-13 WEEK 02-2013 05-JAN-13 11-JAN-13
    11-JAN-13 WEEK 02-2013 05-JAN-13 11-JAN-13
    04-JUN-13 WEEK 23-2013 01-JUN-13 07-JUN-13
    9 rows selected.

  • Function module for retrieving values of the Characteristics?

    Hi,
    is there a function module for retrieving values of the Characteristics?
    will reward,
    regards,
    M.

    Hello,
    Check this.
        L_OBJECT = G_T_STPO-IDNRK.
    *--- Merkmale incl. Bewertung zum Objekt/Klassenart lesen ----------*
        CALL FUNCTION 'CLAF_CLASSIFICATION_OF_OBJECTS'
             EXPORTING
                  CLASSTEXT          = 'X'
                  CLASSTYPE          = '300'
                  FEATURES           = 'X'
                  LANGUAGE           = SY-LANGU
                  OBJECT             = L_OBJECT
                  INITIAL_CHARACT    = ' ' "keine unbewertete M.
                  OBJECTTABLE        = 'MARA'
                  KEY_DATE           = SY-DATUM
    *            NO_VALUE_DESCRIPT  =
                  CHANGE_SERVICE_CLF = 'X'
                  INHERITED_CHAR     = 'X'
             TABLES
                  T_CLASS            =  H_CLASS
                  T_OBJECTDATA       =  H_CLOBJDAT
             EXCEPTIONS
                  NO_CLASSIFICATION  = 1
                  NO_CLASSTYPES      = 2
                  INVALID_CLASS_TYPE = 3
                  OTHERS             = 4.
    Regards,
    Vasanth

  • Change first day of the week from Monday to Sunday(0CALWEEK)

    Hello!
    We have a report that display the data at a calendar week level. The start of the week currently show as Monday( retreived from FM - WEEK_GET_FIRST_DAY).
    Is there a global setting in source system to change the start day of the week from Monday to Sunday? I can always make this change in the transformation but would like to know if there is a global option to make this change so the rest of the reports display the same.
    Thanks
    Sirisha

    You can check this SAP Note 624627 - Sunday first day of the week also a working day (Collective)
    Might be helpful.
    Regards,
    AL

  • Two or more productid will be accquired by same customerid, by same shipvia, on the same day of the week of shipped date. i want the simple query for this.

    consider this situation,
     Two or more productid will be accquired by same customerid, by same shipvia, on the same  day of the week of shipped date. i want the simple query for this.
    my tables are  from northwind:
    [orders] = OrderID, CustomerID, EmployeeID, OrderDate, RequiredDate, ShippedDate, ShipVia, Freight, ShipName, ShipAddress, ShipCity, ShipRegion, ShipPostalCode, ShipCountry.
    [orders details] = OrderID, ProductID, UnitPrice, Quantity, Discount.
    i tried some but it is not exact, it gives wrong result.
    select pd.CustomerID,pd.ProductID, pd.no_of_time_purchased, sd.ShipVia, sd.same_ship_count, shipped_day from
    select ProductID,o.CustomerID,COUNT(productid) as no_of_time_purchased
    from orders o join [Order Details] od on o.OrderID=od.OrderID group by ProductID,o.CustomerID
    having count(od.ProductID) >1) pd
    join
    (select OrderID,customerid, shipvia, count(shipvia)as same_ship_count, DATENAME(DW,ShippedDate)as shipped_day from orders
    group by customerid, ShipVia, ShippedDate having COUNT(ShipVia) > 1 ) sd
    on sd.CustomerID=pd.CustomerID

    Hi,
    I think I have a solution that will at least give you a clue how to go about it. I have simplified the tables you mentioned and created them as temporary tables on my side, with some fake data to test with. I have incldued the generation of these temporary
    tables for your review.
    In my example I have included:
    1. A customer which has purchased the same product on the same day, using the same ship 3 times,
    2. Another example the same as the first but the third purchase was on a different day
    3. Another example the same as the first but the third purchase was a different product
    4. Another example the same as the first but the third purchase was using a different "ShipVia".
    You should be able to see that by grouping on all of the columns that you wich to return, you should not need to perform any subselects.
    Please let me know if I have missed any requirements.
    Hope this helps:
    CREATE TABLE #ORDERS
     OrderID INT,
     CustomerID INT,
     OrderDate DATETIME,
     ShipVia VARCHAR(5)
    CREATE TABLE #ORDERS_DETAILS
     OrderID INT,
     ProductID INT,
    INSERT INTO #ORDERS
    VALUES
    (1, 1, GETDATE(), 'ABC'),
    (2, 1, GETDATE(), 'ABC'),
    (3, 1, GETDATE(), 'ABC'),
    (4, 2, GETDATE() - 4, 'DEF'),
    (5, 2, GETDATE() - 4, 'DEF'),
    (6, 2, GETDATE() - 5, 'DEF'),
    (7, 3, GETDATE() - 10, 'GHI'),
    (8, 3, GETDATE() - 10, 'GHI'),
    (9, 3, GETDATE() - 10, 'GHI'),
    (10, 4, GETDATE() - 10, 'JKL'),
    (11, 4, GETDATE() - 10, 'JKL'),
    (12, 4, GETDATE() - 10, 'MNO')
    INSERT INTO #ORDERS_DETAILS
    VALUES
    (1, 1),
    (2, 1),
    (3, 1),
    (4, 2),
    (5, 2),
    (6, 2),
    (7, 3),
    (8, 3),
    (9, 4),
    (10, 5),
    (11, 5),
    (12, 5)
    SELECT * FROM #ORDERS
    SELECT * FROM #ORDERS_DETAILS
    SELECT
     O.CustomerID,
     OD.ProductID,
     O.ShipVia,
     COUNT(O.ShipVia),
     DATENAME(DW, O.OrderDate) AS [Shipped Day]
    FROM #ORDERS O
    JOIN #ORDERS_DETAILS OD ON O.orderID = OD.OrderID
    GROUP BY OD.ProductID, O.CustomerID, O.ShipVia, DATENAME(DW, O.OrderDate) HAVING COUNT(OD.ProductID) > 1
    DROP TABLE #ORDERS
    DROP TABLE #ORDERS_DETAILS

  • Getting the same day of the week from a previous year in a Power Query calc column

    Hi Power Query users,
    Would like to get your suggestions on this problem. I have a customer that wants to see the previous year's sales for the same day of the week. So today is Friday July 25, 2014. Customer would like to see sales for the closest Friday on the previous year,
    which was Friday July 26, 2013. Next year on Friday July 26, 2015, customer would see the sales for Friday July 25, 2014 and so on. Customer operates 7 days a week, all days of the year including holidays.
    What is the most elegant way to do this? I am assuming the best thing to do is to add this date as a calculated column in the date table, but I am not quite sure the best way to write the formula (including handling of edge cases - leap years, providing
    null when the previous year is not part of the date table, etc).
    I am starting with the
    date dimension as presented by Matt Masson.
    Please help if you have any formula suggestions for this.
    Thanks

    Okay, I'm making a couple of assumptions, so please let me know if these assumptions are incorrect:
    1) Instead of all sales data being in a single column, current year and last year sales are provided in different columns,
    2) The previous year sales column shows the sales occurring on the same
    date as the current year sales (so in your example, 43214 is the sales figure for 6/1/2013.
    If the above assumptions are true, we need to modify how the lookup is done. Let's assume that you created a custom column named SameDayOfWeekLastYear. Create another column called Previous Year Date, using the following function (Date_PreviousYear)
    (date) =>
    let   
        PreviousYearDate = Date.AddYears(date,-1),
        PreviousYearDateAdjusted = if (Date.Day(date)=29 and Date.Month(date) = 2) then
                                       #date(9999,1,1)
                                   else PreviousYearDate
    in
        PreviousYearDateAdjusted
    Incidentally, I created this function the week before your query, for a different purpose. In that case, it was to get the previous year sales occurring on the same
    date as the current year sales. It actually gets to your starting point, but with all the sales data in a single column to start with. However, when the current year is a leap year and you apply the Date.AddYears function, February 29th is calculated
    as February 28th of the previous year. If you then do a lookup for previous year sales, you get February 28th sales looked-up twice (the real Feb 28th and the bogus one resulting from taking February 29th back one year). The PreviousYearDateAdjusted identifier
    puts a truly bogus date instead of a duplicated Feb 28th - one that will always return null when looking up the sales value.
    This new date column will then be used to lookup the row of the previous year sales column that corresponds to the dates in the SameDayOfWeekLastYear column.
    Assuming that the last step in your query is InsertedCustom1, create another custom column (Previous Year Net_Same Day?), which returns the sales on the same day as the current year (the result that you're after). The formula would be:
    LookupValue(InsertedCustom1[Previous Year Net], InsertedCustom1[Previous Year Date], [SameDayOfWeekLastYear])
    where LookupValue is the custom function mentioned previously. After creating this new custom column, you can then remove all of the columns you don't need.
    Hope that the preceding is somewhat clear.

  • Cannot turn on "Show the day of the week" option in Date & Time

    OS X Lion turns "Show the day of the week" option off each time I open that preference pane and after every reboot. My region in Formats tab of Language & Text preference pane is set to "Russia (Russian)". I've noticed that the problem doesn't appear when region is set to US (I didn't try others). Is there any known workaround, except changing my region preference?

    Me too.
    And I have a workaround, until Фззду fixes it finally:
    1) Go to the ~/Library/Preferences, locate a file named com.apple.menuextra.clock.plist, open it with Plist editor (comes with XCode) or just with TextEdit.
    2) There's DateFormat key in it, change it to "EEE H:mm", save the file.
    3) Now Cmd-I (right click - Get info) on that file in Finder, and check option named "Locked" ("Защита").
    System Preferences' Date & Time pane sets the aforementioned DateFormat to "ccc H:mm" when you tick the "Show the day of the week" option, while in Russian locale. And in English it becomes "EEE H:mm". The problem is that Sys.pref and even SystemUIServer (that shows the menu) processes somehow do not like the former value and erase it. After every relaunch of SystemUIServer (after reboot or being killed) tries to change "EEE" to "ccc" again (which would be cleared to nothing next time), that is why you have to lock the plist file.

  • Discovering the day of the week for given date

    hi guys, im trying to discover the day of the week for a given date when i do this it works fine:
    select to_char(sysdate,'FMDAY') from dual
    however, when i try to pass in my own value as a parameter i get the error: invalid number
    select to_char(:mydate,'FMDAY') from dual .
    the value im passing through to mydate is 21/02/2011 so i have no idea why it is not working. Any help would be greatly appreciated. thanks
    Edited by: 786733 on 21-Feb-2011 03:41

    786733 wrote:
    hi guys, im trying to discover the day of the week for a given date when i do this it works fine:
    select to_char(sysdate,'FMDAY') from dual
    however, when i try to pass in my own value as a parameter i get the error: invalid number
    select to_char(:mydate,'FMDAY') from dual .
    the value im passing through to mydate is 21/02/2011 so i have no idea why it is not working. Any help would be greatly appreciated. thanksyou're probably passing in a string instead of a date, so you need to convert it to a date with the appropriate format.
    select to_char(to_date(:mydate,'DD/MM/YYYY'),'FMDAY') from dual

  • Day of the week incorrect in date/time formatting

    This should be a simple fix but I can't seem to find the solution.
    I'm wanting to format my dates using the cell formatting options in the Cells Inspector. Everything is fine except that it's showing the wrong day of the week.
    For example, today is Friday, July 15th, 2011. When I enter 2011-07-15 into the cell, it formats it as Wednesday, July 15, 2011. My time, date and location settings are correct in System Prefs.
    Anyone know where I can fix this? Thanks

    Never mind, I figured it out. I really wish you could delete discussions.

  • Function module to subtract a number of months from a date

    I have a field, FISCPER, in the format YYYY/MMM(2007004) and I need to subtract 12 months off of it to get 2006004.  I tried to just subtreact 12 but it gave me the actual value when you subtract the 2.

    Hi,
    Check the following example:
    FM to Get the Day for a Particular Date
    FM or any other means by which we can get the DAY for a particular date?
    Yes, DATE_COMPUTE_DAY
    Sample code:
      clear: hold_day_of_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.
    or 
    You can use  DATE_COMPUTE_DAY to get the day number of the week (for example, today gives 5)
    then use WEEKDAY_GET which returns an itab with seven entries (one for each day of the week.)
    You enter in this itab and get the field langt to get the day name.

  • Getting the day of the week from a given date help plz

    private String getWeekDay( ) - return the correct week day given the day, month and year for this date.
    I had given this an effort and got stumped, my inital thought was to use mods but any input would be helpful

    try
            int dow = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);

  • DATE FOR FIRST DAY OF THE WEEK

    I am new to Oracle and am looking for a procedure that will calculate the first day of the week given today's date.
    Given 1/23/2000 I need to find Sunday 1/21/2000.

    Hi there,
    I don't think there's a built-in Oracle procedure for what you want. However...
    In SQL (at least, Oracle's SQL), you have the function TO_CHAR and TO_DATE that allow you to convert a date to a string and vice-versa. They work pretty much in a similar way, that is :
    TO_<something>( <data_to_convert>, <format> )
    eg.: To have the day of the week for the current date, you can do
    SELECT TO_CHAR( SYSDATE, 'D' ) FROM DUAL;
    Wednesday, January 24th, 2001 would then return 4.
    To have the day of the year, you would do
    TO_CHAR( SYSDATE, 'DDD' )
    Then, to have the day of the year of the first day of the week, you then could subtract the day of the week of your date from the day of the year of your date, and then add one. To be able to do math stuff of char value, you must use TO_NUMBER.
    In one ugly line, you could do this by doing the following :
    select to_date( (to_char(sysdate,'YYYY') &#0124; &#0124; to_char( to_number( to_char(sysdate,'DDD')) - to_number( to_char(sysdate,'D')) + 1)),'YYYYDDD') from dual;
    Eurk.
    Or you could write a function that would return the date of the first day of the week of a specific date, like :
    create or replace
    FUNCTION FDOW (P_DATE DATE) RETURN DATE
    IS
    R_FDOW DATE;
    BEGIN
    R_FDOW := to_date( (to_char(P_DATE,'YYYY') &#0124; &#0124; to_char( to_number( to_char(P_DATE,'DDD')) - to_number( to_char(P_DATE,'D')) + 1)),'YYYYDDD');
    return R_FDOW;
    END;
    (FDOW : First Day Of Week - not really original, I know)
    Then, you can call it wherever you want:
    SELECT FDOW(SYSDATE) FROM DUAL;
    Have fun!
    Frederic Denis

  • 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

  • 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

  • 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

Maybe you are looking for

  • Error while trying to deploy a cube

    I am getting an error message while trying to deploy a cube. OWB Client version is 10.2.0.1.31 and the repository version is 10.2.0.1.0 Below is the piece of code that generates the error: BEGIN CWM2_OLAP_CUBE.ADD_DIMENSION_TO_CUBE('EXPENSE_WH', 'REL

  • Is it possible to create 2 Date objects with different hashcode.

    Hi, I want to create 2 java.util.Date objects with different hashcodes. Is it possible?? Regards, Farooq

  • Reg Adobe Form

    what is diff between master page and body page , i hve some header data and body data , i want to display that header data in all the pages and only body data will move as per record increases , so will i paste my header data to master one and paste

  • Vmware esx 4.1 (not cisco custom iso) supported on ucs C 24 M3

    Hi, In a test plant I need to install esxi 4.1, not in production network, as it can be done without buying the vmware licenze (custom cisco iso)? Someone did install esxi 4.1 (not cisco custom iso) with success on ucs c serie 24 M3 ?

  • System profiler crashes

    hi, every time i go to open up the system profiler it crashes. the computer does not crash but that one thing does. it opens then it closes right away after it pops up. the message after it close says " The application System Profiler quit unexpected