Dates Of Current Week

Hi Friends,
I want to get the days of the current week along with the dates
I am writing the following code
import java.util.*;
class TryDate
public static void main(String args[])
     Calendar calendar = new GregorianCalendar();
     java.util.Date date=new java.util.Date();
     calendar.setTime(date);
     System.out.println("YEAR : " + calendar.get(Calendar.YEAR));
     System.out.println("MONTH : " + calendar.get(Calendar.MONTH));
     System.out.println("DAY OF MONTH : " + calendar.get(Calendar.DAY_OF_MONTH));
     System.out.println("DAY OF YEAR : " + calendar.get(Calendar.DAY_OF_YEAR));     
     System.out.println("WEEK OF YEAR : " + calendar.get(Calendar.WEEK_OF_YEAR));     
     System.out.println("WEEK OF MONTH: " + calendar.get(Calendar.WEEK_OF_MONTH));     
     System.out.println("DAY OF WEEK : " + calendar.get(Calendar.DAY_OF_WEEK));     
I am getting the output as
YEAR : 2004
MONTH : 6
DAY OF MONTH : 23
DAY OF YEAR :205
WEEK OF YEAR : 30
WEEK OF MONTH: 4
DAY OF WEEK : 6
My question is I want to get the dates of the current week of current year i.e. week30 of year 2004
How do i get it?
Thanx
Pooja

hello here is your solution.
you can see the code which I given here
If you want any difficulty thn contact me at [email protected]
import java.util.*;
public class WeekDates {
public static void main(String args[])
Calendar calendar = new GregorianCalendar();
java.util.Date date=new java.util.Date();
calendar.setTime(date);
System.out.println("YEAR : " + calendar.get(Calendar.YEAR));
System.out.println("MONTH : " + calendar.get(Calendar.MONTH));
System.out.println("DAY OF MONTH : " + calendar.get(Calendar.DAY_OF_MONTH));
System.out.println("DAY OF YEAR : " + calendar.get(Calendar.DAY_OF_YEAR));
System.out.println("WEEK OF YEAR : " + calendar.get(Calendar.WEEK_OF_YEAR));
System.out.println("WEEK OF MONTH: " + calendar.get(Calendar.WEEK_OF_MONTH));
System.out.println("DAY OF WEEK : " + calendar.get(Calendar.DAY_OF_WEEK));
Date startDt=new Date();
startDt.setDate((calendar.get(Calendar.DAY_OF_MONTH)-calendar.get(Calendar.DAY_OF_WEEK))+1);
for(int i=0;i<=6;i++)
     Date dt=new Date();
     dt.setDate(startDt.getDate());
     startDt.setDate(startDt.getDate()+1);
     System.out.println(" Date "+(i+1)+ ": "+dt.toString());
}

Similar Messages

  • How to get data for current week and previous week using customer exit in Bex.

    Hi everyone,
    I have a scenario in which I need to display data for current week and previous week (based on "sy_datum" the program has to calculate current week and previous week) in Bex using  Customer exit. I have created one variable in Bex Query Designer and I have written code for the variable in CMOD. But it is not working fine, (I know that we can do the same by using offset value in Bex). Can some one guide me how to achieve my requirement using customer exit.
    Thanks in Advance,
    G S Ramanjaneyulu.

    Hi krishna,
    Thanks for your quick reply, can you have a look at my code,
    case i_vnam.
    WHEN 'ZPWK_CWK'.
    ranges : pre_week for sy-datum.
    data : start_date type DATS,
           end_date TYPE dats .
    ************FM TO GET FIRST DATE OF CURRENT WEEK ************************
    CALL FUNCTION 'BWSO_DATE_GET_FIRST_WEEKDAY'
      EXPORTING
        DATE_IN  = sy-datum
      IMPORTING
        DATE_OUT = start_date.   " WEEK FIRST DATE
    end_date = START_DATE + 6.   " WEEK LAST DATE
    END_DATE   = START_DATE - 1.   " PREVIOUS WEEK END DATE
    START_DATE = START_DATE - 7.   " PREVIOUS WEEK START  DATE
    **********PREVIOUS WEEK DATES IN PRE_WEEK******************
    pre_week-SIGN   = 'I'.
    pre_week-option = 'BT'.
    pre_week-LOW    = START_DATE.
    pre_week-HIGH   = END_DATE.
    APPEND  pre_week.
    CLEAR : START_DATE,END_DATE.
    endcase.
    Regards,
    G S Ramanjaneyulu.

  • How to calculate start date and last date for current week

    Dear All.
    i want to calculate the start of the current week as well as the last date of the current week, our week start from Saturday and ends of Friday i.e. Saturday is the first day of the week and Friday is the last day of the week.
    How can i acheive this in universe Designer?.
    Please help...

    Hi
    the formulas in webi will be as follows
    for startdate
    =RelativeDate(LastDayOfWeek(CurrentDate());-8)
    for enddate:
    =RelativeDate(LastDayOfWeek(CurrentDate());-2)
    Regards,
    Ranganath

  • Getting the exact date of current week and current month

    I would like to know is there any methods to know the exact date of the current week and current month?

    //use this function like this
    //String date = getNow();
    public static String getNow()
         Calendar cal = new GregorianCalendar();
         // Get the components of the time
         int hour24 = cal.get(Calendar.HOUR_OF_DAY); // 0..23
         int min = cal.get(Calendar.MINUTE); // 0..59
         int sec = cal.get(Calendar.SECOND); // 0..59
         // Get the components of the date
         int year = cal.get(Calendar.YEAR); // 2002
         int month = 1 + cal.get(Calendar.MONTH); // 0=Jan, 1=Feb, ...
         int day = cal.get(Calendar.DAY_OF_MONTH); // 1...
         String timeStamp = String.valueOf(year) + "-" + addZero(month)+ "-" + addZero(day)
              + " " + addZero(hour24)+ ":" + addZero(min) + ":"+ addZero(sec) + ".0";
         return timeStamp;
    public static String addZero(int num)//this function works with the getNow() function
    //all it does is adds a zero to an int if its less then ten
         String val = "";
         if(num < 10)
         val +="0"+num;
         }else{
         val = String.valueOf(num);
         return val;
    }

  • ASCP Planned orders recommendation date for current week

    Dear Experts,
    I am facing the below issue in Decentralized ASCP workbench.
    In the forecast demand date is 18-04-11, 25-04-11, 02-05-11 and so aon (Weekly buckets).
    After launching plan today (18-04-11), Recommendation in workbench are showing due dates as 19-04-11, 25-04-11, 02-05-11 and so on.
    The question here is, Why the current week demand is shifting one day (19-04-11). Business requirement is today (18-04-11).
    Appreciating your valuable soluation.
    Note:
    (We checked planning time fence. Items having the value 0, 1 are also giving the same result)
    Regards,
    Ramesh

    Sandeep Gandhi,
    Yes, ASCP can not schedule anything in the past but it will suggest planned orders for today (Plan run date) for the past demands.
    Example: Forecast Demand due date : 16-04-11.
    when we run the plan today, ASCP have to suggest planned order for today's due date (18-04-11)
    But we don't know why it is shifting to 19-04-11 (tomorrow).
    Your valuable suggests will be very helpful
    Regards,
    Ramesh

  • Query to get data for current week+13

    Hi Friends,
    I have two tables
    BACKLOG_WEEK_AFTER_ATP (LE)
    BACKLOG_ATP_GT_CW (RE)
    ** First I have to query whats the current week and year and it should come in this format ---- 2011-WK30
    columns in table BACKLOG_WEEK_AFTER_ATP are:
    ITEM_NUMBER      QUANTITY
    1N5418                 20
    1N5614                 30
    1N5806SM               10
    1N5811                  0
    2PFF6                  60columns in table BACKLOG_ATP_GT_CW are:
    ITEM_NUMBER     QUANTITY        YEAR_WEEK
    1N5418                30        2011-WK30
    1N5418                 5        2011-WK31
    1N5614                30        2011-WK32
    1N5806SM              30        2011-WK33
    1N5811                20        2011-WK32
    3EX473K1              20        2011-WK30My report should look like
    ITEM_NUMBER    2011-WK30  2011-WK31  2011-WK32  2011-WK33  ...............till 13th week
    1N5418                10         -5         -5         -5  ...............till 13t week
    1N5614                30         30          0          0  ................till 13th week
    1N5806SM              10         10         10         20  ................till 13th week
    1N5811                 0          0         20         20  ................till 13th week
    2PFF6                 60         60         60         60  ................till 13th week
    3EX473K1              20         20         20         20  ................till 13th weekTo get this report i have these conditions to keep in mind.
    1) If item_number not present in LE table and present in RE table then repeat what it is in RE table till 13th week
    2) If item_number not present in RE table and present in LE table then repeat what it is in LE table till 13th week
    3) If item_number present in LE and also present in RE table then do subtraction for RE - LE for that particular item_number till 13th week.
    4) If item_number is there in LE table but not present in RE table for current_week+1(today week comes as 29th week) then repeat the same which is there in LE table. If item is found in RE table for (example 32th week) then subtract RE -LE for that particular item_number
    Thanks in advance.
    Regards

    Hello,
    If you don't need the PIVOT display, then this may help you :
    with le as
    (select '1N5418' item_number, 20 quantity from dual union all
    select '1N5614' item_number, 30 quantity from dual union all
    select '1N5806SM' item_number, 10 quantity from dual union all
    select '1N5811' item_number, 0 quantity from dual union all
    select '2PFF6' item_number, 60 quantity from dual ),
    re as
    (select '1N5418' item_number, 30 quantity, '2011-WK30' year_week from dual union all
    select '1N5418' item_number, 5 quantity, '2011-WK31' year_week from dual union all
    select '1N5614' item_number, 30 quantity, '2011-WK32' year_week from dual union all
    select '1N5806SM' item_number, 30 quantity, '2011-WK33' year_week from dual union all
    select '1N5811' item_number, 20 quantity, '2011-WK32' year_week from dual union all
    select '3EX473K1' item_number, 20 quantity, '2011-WK30' year_week from dual
    row_gen as (
    select item_number, calc_year_week,
           row_number() over(partition by item_number order by calc_year_week) rn
    from
        (select le.item_number from le union select item_number from re) item,
        (select to_char(level*7+sysdate,'YYYY-"WK"WW') calc_year_week from dual connect by level<=13) week)
    select item_number, calc_year_week, calc_qty
    from row_gen, le, re
    where row_gen.item_number=le.item_number(+)
    and row_gen.item_number=re.item_number(+)
    and row_gen.calc_year_week=re.year_week(+)
    model
    partition by (row_gen.item_number)
    dimension by (rn)
    measures (calc_year_week, year_week, le.quantity le_qty,re.quantity re_qty,0 calc_qty )
    rules  (
    calc_qty[1]  =
        case when re_qty[cv()] is null then le_qty[cv()]
        when le_qty[cv()] is null then re_qty[cv()]
        else  re_qty[cv()]-le_qty[cv()]
    end,     
    calc_qty[rn>1] order by rn =
        case when re_qty[cv()] is null then calc_qty[cv()-1]
        else re_qty[cv()] - calc_qty[cv()-1]
        end           )
    order by 1,2;I am not sure this is the simplest way to do it, but the results seem to match your example.
    Regards,
    Sylvie
    Edited by: Troll35 on Jul 19, 2011 3:08 PM

  • Current week Highlighted in Colour

    Hello Gurus,
    I have one report in which we are showing data for current week alongwith the previous four weeks data.User wants the current week to be highlighted with the colur. Is it possible in Bex?.My colmns contains calweeks and in rows  I have Keyfigures.
    Please add your suggestions.

    Hi Deepak,
    You can create exception with refernce to the calweek characteristics.
    Or in BW 7.0 we have highlight option available for the keyfigure under the display tab in properties.
    Hope it helps.
    Regards,
    Umesh.

  • I recently upgraded to iWork v9.0.3, but when I access each applications the versions are different (i.e. Pages V.4.1, Numbers V2.6, Keynote V5.1.1) with a install date of 3/18/09 -- which is not the current install date of 2 weeks ago. Why?

    I recently upgraded to iWork v9.0.3, but when I access each applications the versions are different (i.e. Pages V.4.1, Numbers V2.6, Keynote V5.1.1) with a install date of 3/18/09 -- which is not the current install date of 2 weeks ago. Shouldn't Pages, Numbers, and Keynote show version 9.?? My MAC confirned installation of v9.0.3 and even accepted the software code. With this discrepancy, how can I determine if the latest was installed and operational? I even downloading v9.0.4, 9.0.5, and 9.1. When I tried installing these downloads it popped up note stating that a later version of Keynote was already installed.

    You used the data.  Verizon can not see what it was sued for.  However your phone can see whats apps used the data.  go to settings-data usage- there will be a place that says data usage cycle.  line the dates up with your cycle.  then there will be a bar graph below that   extend bother white bars one all the way to the left and one all the way to the right.  after those are extended below that will be a list of apps,  there should be one that used over 2 gb and that will show you what app used that data in her purse

  • How to get date range of Current week

    Hi Gurus,
    I need to create report of current(this) week manual bills created by one user. I have date Field called CREAT_DATE.Based on this date column i need to create report.
    Could anybody help to get this query.
    Example:
    select .....
    from ....
    where
    CREAT_DATE
    Thank You
    Vikram

    It kind of depends on your definition of "current week". If you mean something like the last 7 days, then
    SELECT columns
    FROM table
    WHERE creat_date BETWEEN TRUNC(sysdate - 7) and TRUNC(sysdate +1)would do it.
    If you mean Monday until today, then:
    SELECT columns
    FROM table
    WHERE creat_date BETWEEN NEXT_DAY(TRUNC(sysdate - 7), 'MONDAY') and TRUNC(sysdate +1)Read up on the various date functions for other possibilities.
    TTFN
    John

  • Current date, first day of month, last day of month, current week, current

    Hi All,
    may be the question will sounds basic for your guys, I am connecting via MDX a cognos reportnet on a BW 3.0B..due to loads of limitations on filtering via MDX on 'business date/time functions' , I would need to create in the infoqueries that are my data sources, the following additionnal objects:
    - current date
    - first day of current month
    - last day of current month
    - current week
    - current year
    I do not want prefiltered infoqueiries but object with these single values so that from reportnet I can have something like: OCALDAY between 'first day of current month' and 'last day of curent month'
    Is there standard fonction for this under BW/BEX or if we need to developp functions has nayone some code examples.
    thanks a lot for your great input
    David

    Hi,
    In universe level if you want implement the requirede functions then you have to write custom sql and if you want to implement them in Reporting level then most of the functions are available to you. e.g. Quarter,Month, Year, Current Date....
    Cheers,
    Suresh A.

  • Get the Current Quarter  and Current Week from date

    Hi,
    I want to get the Current quarter and Current week from a given date, which function modules should i use?
    I tried using function module - 'HR_99S_GET_QUARTER' for getting the quarter but it is throwing an error while loading data. Moreover it doesnt exist in BI7.
    Similarly for current week.
    Please help. Sample code snippets would be appreciated.
    Thanks
    Jaya

    You can use FORM time_conversion wich is the one used by standard in Update Rules:
    You can select whether convert 0CALDAY to 0CALWEEK or whatever infobject formats you prefer...
      perform time_conversion
                using  '0CALDAY'
                       '0CALMONTH'
                        p_input_date
                        l_fscvtval
                changing RESULT
                         c_t_idocstate
                         c_subrc
                         c_abort.
      if c_subrc <> 0 or c_abort <> 0.
        exit.
      endif.
    form time_conversion
                   using i_timnm_from type rsiobjnm
                         i_timnm_to   type rsiobjnm
                         i_timvl
                         i_fiscvarnt  type t009b-periv
                   changing e_timvl
                            c_t_idocstate  type rsarr_t_idocstate
                            c_subrc   like sy-subrc
                            c_abort   like sy-subrc. "#EC *
    data: l_timvl  type rsd_chavl,
          l_result type rsd_chavl.
      IF i_timvl CO ' 0'.
        CLEAR e_timvl.
        EXIT.
      ENDIF.
      l_timvl = i_timvl.
      CALL FUNCTION 'RST_TOBJ_TO_DERIVED_TOBJ'
        EXPORTING
          i_timnm_from             = i_timnm_from
          i_timnm_to               = i_timnm_to
          i_timvl                  = l_timvl
          I_FISCVARNT              = i_fiscvarnt
          I_BUFFER                 = rs_c_true
        IMPORTING
          E_TIMVL                  = l_result
        EXCEPTIONS
          INCOMPATIBLE_TOBJS       = 1
          NO_INPUT_VALUE           = 2
          FISCVARNT_MISSING        = 3
          INPUT_NOT_NUMERIC        = 4
          WRONG_DATE               = 5
          WRONG_FISCPER            = 6
          X_MESSAGE                = 7
          OTHERS                   = 8
      e_timvl = l_result.
    ENDFORM.                  "TIME_CONVERSION

  • Current week/current Month/YTD data based on user response

    Hi
    I have one attribute request_created_date
    Based on this i want to create one more attribute which will have lovs as week(Request_created_date for current week),monthly(Request_created_date for current week),
    YTD(Request_created_date for current year to date).
    Now i want to use this new attribute (Having LOV as week/Month/YTD) as a report prompt so that user itself can select whether he wants to see
    week/month/YTD data in report.
    To Add to this :
    Req is something like this if user select week , Req_created_dates should be filtered for all the dates of cureent week.
    Req is something like this if user select month , Req_created_dates should be filtered for all the dates of cureent month.
    Req is something like this if user select Year , Req_created_dates should be filtered for all the dates of cureent year.
    How can i achieve this?

    Add One variable
    Time_Data ="Weekly"
    Create Input control (Radio Button)
    Use Custom LOVs (Add Weekly , Monthly , Yearly ).
    Set Default (Weekly).
    Now Create Another Variable
    User_Want = ReportFilter([Time_Data])
    Now filter your Report for week , Month or Year (as per Selection) using If else Statement .
    For eg.
    For Week
    [Created_Date] Between RelativeDate(CurrenDate();-7) And CurrentDate()
    For Month
    (Year([Created_Date]) = Year(CurrentDate())  And Month([Created_Date]) = Month(CurrentDate()))
    For Year
    (Year([Created_Date]) = Year(CurrentDate())

  • BI Routnie in DTP to calculate current week from current date

    Hello Team
    I want to write routinue to calculate current week based on date
    For eg, this week is
    201410, so the routine will get 201410 based on today’s date 4 Mar 2014.
    Can any1 please help
    Regards,
    Ankit

    I had written following code its giving error like
    E:Field "/BI0/9AVERSION" is unknown. It is neither in one of the
    specified tables nor defined by a "DATA" statement. "DATA" statement.
      data: l_idx like sy-tabix.
      read table l_t_range with key
           fieldname = '/BI0/9AVERSION '.
      l_idx = sy-tabix.
    Data: Date Like scal-date.
    Data: week like scal-week.
    call function 'DATE_GET_WEEK'
    exporting
    date = sy-datum
    importing
    week = SOURCE_FIELDS-/BI0/9AVERSION
    exceptions
    date_invalid = 1
    others = 2.
    * Return code <> 0 means skip whole data package !!!
    returncode = 0.

  • How to identify which is current week by java.util.Date

    below code wriiten to identify number of weeks in a given month,
    i need current week in a from below code.Can any one help me?
    for(int i=1;i<32;i++){
    Date d = new Date(2005,11,i);
    intMonDtTemp=d.getMonth();
    0-sunday
    1-monday
    5-friday
    6-saturaday
    // number of weeks is based on monday's in given month
    //System.out.println(intMonDtTemp+" at =month dt "+ intMonDt);
    if(intMonDtTemp==intMonDt){
         //System.out.println(i+" = "+ d);
         //System.out.println("MONTHS EQUAL");
         if(d.getDay()==1){
              count= count+1;
    }//end of for
    if(count==5){
         System.out.println(strDt+" = 5 weeks");
    } else {
         System.out.println(strDt+" = 4 weeks");
    }//end of else

    using Calendar, not Date
    import java.util.Calendar;
    class Testing
      public Testing()
        Calendar cal = Calendar.getInstance();
        int month = Calendar.OCTOBER;// months are 0-based 0-11, not 1-12
        cal.set(2005,month,1);
        int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
        if(dayOfWeek > 2) dayOfWeek -= 7;
        cal.add(Calendar.DATE,2 - dayOfWeek);
        int mondaysInMonth = 0;
        while(cal.get(Calendar.MONTH) == month)
          cal.add(Calendar.DATE,7);
          mondaysInMonth++;
        System.out.println("Mondays in month = "+mondaysInMonth);
      public static void main(String[] args){new Testing();}
    }

  • How can I get the Thursday of current week as a date?

    Is it possible to get Thursday of the current week as a date, using a select statement?
    For example, no matter what day of the week it is when I run the query, I'll get the Thursday of the current week in date form.
    It should be really simple, but I'm still scratching my head on this. Thanks!

    SELECT DATEADD(wk, DATEDIFF(wk,0,GETDATE()), 3) ThursdayOfCurrentWeek
    Hope this helps
    Thanks,
    Nihar
    SELECT DATEADD(wk, DATEDIFF(wk,0,GETDATE()), 3) ThursdayOfCurrentWeek

Maybe you are looking for

  • If your web pages are loading slowly, this resolved my issue.Hope it helps!

    Mac OS: Long delay before webpages load, then load suddenly at normal speed Symptoms When trying to access a website via its DNS name, such as www.apple.com, there may be a delay that ranges from several seconds up to several minutes before the page

  • Re: Reason Of Rejection field in the Sales Order screen in IC Web client

    Hi guys WE have implemented CRM 6.0 & ECC 6.0 Our call center guys login to IC Webclient to place Standard Orders in the CRM system which replicates to ECC. Now as most of us know that the Order cannot be rejected once a Delivery Document is created

  • Gridbag Layout In Flex - Looking for canvasgrid

    Hello, I found a posting about a layout mechanism call canvasgrid, based on the gridbag layout principle. It is documented at Mannu's Blog. It is a very effective layout, but the download is broken, and so If anyone happens to have his open source re

  • Refund a weird payment due to a lag ?

    Hello everyone, After having lagg hard this morning, i received an email from apple saying that i've been charged $100 for something i never tryied to buy and the worst thing is that i don't even have the contain of the pack. I contacted the company

  • Advice on creating VARCHAR2(4000) columns

    Hi there I've a question regarding table(s) design. Following is a table, which has about 10,000 rows. As you can see there are two VARCHAR2(2000) columns. All rows have these columns with data which are always "full" (avglength = 2000). CREATE TABLE