How to get the date of first day of the week

hi ,
how can i get the first day of the current week ?
i have tried the following
note : my sysdate is 3rd april 2007
select trunc(sysdate , 'ww') from dual -- 4/2/2007
select trunc(sysdate , 'w') from dual -- 4/1/2007
select trunc(sysdate - 4 , 'ww') from dual -- 3/26/2007 -- shld return 25th mar 2007
select trunc(sysdate - 4 , 'w') from dual -- 3/29/2007 -- shld return 25th mar 2007pls advise
tks & rgds

Hi!
I'm considering MONDAY as the first working day of the current week. And, the code is accordingly --
SQL> select to_char(sysdate - to_number(decode(to_char(sysdate,'DY'),'TUE','1',
  2                               'WED','2',
  3                               'THU','3',
  4                               'FRI','4')),'dd-mon-yyyy') res
  5  from dual;
RES
02-apr-2007Regards.
Satyaki De.

Similar Messages

  • How to get the date of first day of a week for a given date

    Hi gurus
    can any one say me how to get the date of first day(date of Sunday) of a week for a given date in a BW transformations. For example for 02/23/2012 in source i need to get 02/19/2012(Sunday`s date) date in the result. I can get that start date of a week using  BWSO_DATE_GET_FIRST_WEEKDAY function module. But this function module retrieves me the  start date as weeks monday(02/20/2012) date. But i need sundays(02/19/2012) date as the start date. So it would be really great if anyone sends me the solution.
    Thanks
    Rav

    Hi,
    The simplest way would be to subtract 1 from the date date which you are already getting in transformation routine, but instead of doing that subtraction manually which might need bit of errort, you can simply use another FM to subtract 1 from given date.
    RP_CALC_DATE_IN_INTERVAL
    Regards,
    Durgesh.

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

  • 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

  • How to get two date difference in Day/hour/min/secs pl

    First of all,
    Hello to All, i am new to Oracle DB, but i have little experience in Other Database such as Sybase, sql server etc
    please kindly help me
    in DoctorChart table i have DocName,Id#,Citcotype,Medtype,AdmitDate,DischargeDate(both admitdate & Discharge date is date formatted columns)
    so how can i get the below differenceTime (which means Dischargedate-Admit Date in below format i.e, Day,Hours,Minutes,Seconds...)
    DoctorName, ID #, Citco type, MEDtype, DifferenceTime
    ========= === ======= ======= ===========
    Dr. KindaEmesko, 20045, Replace OutCard, ICH, 0 day 9 hours 11 minutes
    Dr. KindaEmesko, 20098, Replace OutCard, ICH, 1 day 2 hours 34 minutes
    Dr. KindaEmesko, 20678, Replace OutCard, ICH, 2 day 23 hours 52 minutes
    Dr. KindaEmesko, 20212, Replace OutCard, ICH, 4 day 1 hours 00 minutes
    Dr. KindaEmesko, 20345, Replace OutCard, BED, 3 days 14 hours 15 minutes
    Dr. KindaEmesko, 20678, Replace OutCard, BED, 9 days 21 hours 52 minutes
    Dr. KindaEmesko, 20015, Signature Overlay, Rest, 0 days 3 hours 29 minutes
    Dr. KindaEmesko, 45678, Signature Overlay, Rest, 0 days 1 hours 29 minutes
    Same way how can i get the Average Time for the above result (without ID columns)
    DoctorName, Citco type, MEDtype, Avg DifferenceTime
    ========= === ======= ======= ===========
    Dr. KindaEmesko, Replace OutCard, ICH, 2 day 1 hours 00 minutes
    Dr. KindaEmesko, Replace OutCard, BED, 6 days 17 hours 15 minutes
    Dr. KindaEmesko, Signature Overlay, Rest, 0 days 2 hours 29 minutes
    Please just tell me how to get the two dates difference as day/hour/minute format
    as well as how to get avg ( two dates difference as day/hour/minute format)
    Please Help me
    Thanks in advance

    Well, instead of all these suggested manipulations you can simply use intervals. Oracle uses day as a unit in date arithmetic, so Dischargedate-Admit Date is number od days between two dates. Built-in function numtodsinterval can be used to convert it into interval. For example:
    SQL> with t as (
      2             select trunc(sysdate) - 2 Admit_Date,
      3                    sysdate            Discharge_Date
      4               from dual
      5            )
      6  select  numtodsinterval(Discharge_Date - Admit_Date,'DAY') Hospital_Stay
      7    from  t
      8  /
    HOSPITAL_STAY
    +000000002 00:01:08.000000000
    SQL>  SY.

  • How to get a data element's value from the data file while bursting

    For faxing bursted data into rightafx, I need to first burst my invoice data file into numerous pdf files in the filesystem, and then use the rightfax function of the delivery manager to send those files to different faxes. Integration with rightfax is not available in the bursting engine.
    While bursting the xml data file based on invoice number, I need to get the fax number that is different for each invoice in a java variable so that I can use it to pass fax number information to rightfax. Is it possible?
    Thanks.

    Can any one help?
    Edited by: MTW on Apr 16, 2010 6:58 AM

  • Set flag in DB if the date is 5 days in the past

    I've written some code using SQL that checks today's date and compares is to an entry in the database, which I have called EndDate.  If the EndDate is within 60 days an email will be generated. If data in the database is 60 days or more in the future
    it returns the data from the query.
    Here is the code:
    Use LOGONs
    Select DateAdd(d, DateDiff(d, 0, EndDate), 0) As KeyedDate, Service, Manufactureer, [AccountNumber], GETDATE() as TodayTime
    From ServiceExpiryMAtrix
    where DATEDIFF(d, GETDATE(), EndDate) < 60
    I have created another column in the database called expired, that I'd like to update with either yes or no if the Enddate field is over 5 days old.  The idea behind this is to control whether emails are continued to be sent once the EndDate date has
    passed.
    I have seen that this should be done in the select query but being new to SQL I thought I'd ask the question...
    James
    Alter De Ruine

    This way you don't have to update any column every day.
    Each time you select your table it'll give you the correct value.
    If you want to stick with updating just do this:
    UPDATE LOGONs SET Expired = case when datediff(day,getdate(),[EndDate])>(5) then 'yes' else 'no'  end
    WHERE isnull(Expired,'') <> case when datediff(day,getdate(),[EndDate])>(5) then 'yes' else 'no'  end
    or
    UPDATE LOGONs SET Expired = case when datediff(day,getdate(),[EndDate])>(5) then 'yes' else 'no'  end
    WHERE isnull(Expired,'no') = 'no'
    Then you can set the default value for your column to 'no'  and only update to 'yes'....
    "If there's nothing wrong with me, maybe there's something wrong with the universe!"

  • Date for first day of current month

    How can i get the date for first day of current month ?

    select trunc(sysdate,'MM'),to_char(trunc(sysdate,'MM'),'DD'),to_char(trunc(sysdate,'MM'),'Day') from dual;

  • Changing the first day-of-the-week on the MyTimesheets app

    IN the SAP ECC and Portal implementations of the timesheet app, we were recently able to change the display so the first day of the week is listed as Monday, rather than Sunday. I would like to do the same thing with Fiori.
    That is, when the app starts up the first view a calendar view of the whole month. If a person wants to enter time manually, they click the button labeled "manual" and a data entry screen pops up. The first day of the week listed across the top is Sunday, which does not reflect our settings in ECC. We need the 1st day of the week to be Monday.
    Is there a configuration change we can make to force the 1st day of the week to be Monday, as it is in ECC?
    thanks for your help!
    -Rob Solomon

    Hi Rob,
    Are you using Wave2 app? You could change the setting for first day of the week in CAC1 and Fiori Timesheet app will adjust te calendar accordingly.
    Nothing needs to be done for Fiori app.
    Please update UIX01HCM to SP03 if you are using Wave2 app?
    Best Regards
    Pankaj

  • Default parameter to first day of the year

    Hi,
    I am looking to put default value of the parameter to first day of the year. Help me
    Thanks
    susheel 
    sush

    Use this expression as Default Value for parameter:
    =DateSerial(YEAR(Today()), 1, 1)
    - Vishal
    SqlAndMe.com

  • How to get the first day in the month from a domain date ?

    Hi,
    I like to know how to get the first day in the month from a domain date?
    Thanks
    Stephen

    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

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

  • Function Module to get first day of the fiscal year on passing a date

    Hi Experts!!
    Can you please suggest a Function Module to get first day of the fiscal year on passing a date..?
    Example:  if a fiscal year starts from 30 November 2009 and ends at 28 november 2010.
    it should return 30 th nov 2009 (first day of the fiscal year)

    Moderator message - Welcome to SCN.
    I think you'll find that this question has been answered before. Please search the forum before posting.
    Also, Please read Please read "The Forum Rules of Engagement" before posting!  HOT NEWS!! and How to post code in SCN, and some things NOT to do... and [Asking Good Questions in the Forums to get Good Answers|/people/rob.burbank/blog/2010/05/12/asking-good-questions-in-the-forums-to-get-good-answers] before posting again.
    Rob

  • 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

Maybe you are looking for

  • How can I permit all traffic from inside-dmz-outside on asa5505

    Scenario : Servers are in DMZ, Internal LAN Users should access ports Specified (5000 & 2048). Router 2801 is facing Leased line; from there it’s connected to firewall. Router LAN IP: 83.111.X.X - 255.255.255.X ASA Version 7.2(4) hostname ciscoasa do

  • A Problem with Region Format Settings

    Hi! I have a peculiar problem with Region Format settings on my iPod touch (Settings > General > International > Region Format). It appears that iPod touch can support more region formats than it is stated on that list. Once I registered my iPod, I s

  • PDF file looks fine but prints fuzzy

    Hi, I am making music books for a publishing company and we are having an issue with some PDF's. To let you know what we are dealing with I will provide you with some critical info. I recieve 600 DPI scans as PDF's of books with music in them from ou

  • Problem printing Special Characters in Smartform

    Hi, I am developing a Smartform for Position Description. For that I have to display data from table HRT1002 as the data in this table is stored using Text Editor the data internally is stored in '#' when there is a enter, space or some special Chara

  • CSA 5.1 and Spotlight from Quest Software

    I am having an issue getting Spotlight to connect to any Exchange servers (This server is an OMA server) to monitor them if the CSAgent is installed. Has anyone run across this issue before? I thought maybe it was one of the rules, but I put the agen