Monday's Date  of the given week  and year

Hi gurus,
I have the data for week ( eg.52 ) and year ( eg. 08 ) and I need to get the date of the Monday of that week (21-DEC-2008...i.e 52th week of 2008 Year.)
Pls let me knw the sql statement solution for this ..
THanks,
shashi..

Hi, Shashi,
There's a bug in what I posted before.
Do this instead:
TRUNC ( TO_DATE ( '01-Jul-' || :year_txt
                , 'DD-Mon-YYYY'
      , 'IY'
      ) + (7 * (:week_val - 1))The only change is in TO_DATE.
Here's the problem.
TO_DATE won't work with ISO years; it only takes calendar years.
When you don't specify a day and month in TO_DATE (like I originally did) it defaults to the first day of the current month. So TO_DATE ('2011', 'YYYY') returns October 1, 2011 when the current month is October, and it returns January 1, 2011 when the current month is January.
January 1, 2011, however, is in ISO year 2010. (ISO 2011 begins on the Monday closest to January 1, which is January 3, 2011). My original solution, therefore, would return dates from ISO year 2010 when anyone asked for year 2011 and they happend to be running the program during January.
Specifying a full date makes the expression behave the same regardless of when it is run.

Similar Messages

  • DATE FROM THE GIVEN WEEK NUMBER AND YEAR

    hi to all
    With weeknr, yearnr  i need to find STARTDATE  (first day of the week), ENDDATE (last day of the week) The first day of the week is always a Monday.
    example 44 2007
    week nr is 44
    year is 2007
    how to find it.
    is there any standard function module to find.
    regards
    prathap

    hi prathap,
    WEEK_GET_FIRST_DAY For a given week (YYYYMM format), this function returns the date of the Monday of that week.
    try using this function module...
    some other function modules may be helpful...
    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_GET_WEEK will return the week that a date is in.
    DATE_IN_FUTURE Calculate a date N days in the future.
    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.
    reward if helpful
    regards,
    sravanthi.

  • Problem in retreiving data for the given user parameter year!!!

    hi all,
    I am working in oracle report 6i. I want to display the data for the date given in the parameter field(MM/YYYY).
    For ex. Input is 07/2007 means i want to display the data from 04/2006 to 07/2007.Please guide me
    to get this desire output......
    Here is my query.....
    select gl_code,financial_month,financial_year,division_code
    from gtemp
    where financial_year between to_number(to_char(:P_Date,'YYYY')) - 1 and to_number(to_char(:P_Date,'YYYY'))
    and financial_month >= '04'
    and financial_month < = to_char(:P_Date,'MM')
    and division_code = 11
    order by financial_month, financial_year
    regards,
    jame
    Message was edited by:
    Jame

    Works fine if u gave values instead of variables.... But if we gave 02 in place of 11 like below.Query will get
    confused to take which years 02 because in both 2005 and 2006 we have 02(Feb)thats y.......
    how to overcome this prob.......I think, my entire query is wrong to get this desire output....Please guide me how
    to solve......
    select gl_code,financial_month,financial_year,division_code
    from gtemp
    where financial_year between 2005 and 2006
    and financial_month >= '04'
    and financial_month < = '02'
    and division_code = 11
    order by financial_month, financial_year

  • Find the difference between two dates for the specific month and year

    Hi,
    I have two dates, start date is 30/12/2012 and end date is 04/01/2013. Using datediff I found the difference of days between two dates. But I find the no of days in January 2013. ie output is 4 instead of 6. I input month and year to find the no of days
    for that date. In this case I input Jan 2013. How can I sql this ?

    I don't understand how most of the answers provided here not analytically solving the problem with many cases possible.
    First let me understand you:
    You have 2 dates range and you want to calculate day range for specific month and year between the original date range.
    declare @for_month int = 1 --January
    declare @for_year int = 2013
    declare @StartDate date = '2012-12-20'
    declare @EndDate date = '2013-01-04'
    SELECT
    CASE
    WHEN (DATEPART(MONTH, @StartDate) = @for_month and DATEPART(MONTH, @EndDate) = @for_month) and ((DATEPART(YEAR, @StartDate) = @for_year or DATEPART(YEAR, @EndDate) = @for_year)) THEN
    DATEDIFF(DAY, @StartDate,@EndDate)
    WHEN (@StartDate < cast(CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as date)) and (@EndDate between (cast(CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as date)) and (cast(DATEADD(d, -1, DATEADD(m, DATEDIFF(m, 0, cast( CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as date)) + 1, 0)) as date))) THEN
    DATEDIFF(DAY, DATEADD(MONTH, DATEDIFF(MONTH, -1, @EndDate)-1, 0),@EndDate)
    WHEN (@EndDate > cast(DATEADD(d, -1, DATEADD(m, DATEDIFF(m, 0, cast( CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as date)) + 1, 0)) as date)) and (@StartDate between (cast(CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as date)) and (cast(DATEADD(d, -1, DATEADD(m, DATEDIFF(m, 0, cast( CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as date)) + 1, 0)) as date))) THEN
    DATEDIFF(DAY, @StartDate,DATEADD(d, -1, DATEADD(m, DATEDIFF(m, 0, @StartDate) + 1, 0))) + 1
    WHEN ((DATEDIFF(DAY, @StartDate, cast(DATEADD(d, -1, DATEADD(m, DATEDIFF(m, 0, cast( CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as date)) + 1, 0)) as date)) >= 0) and (DATEDIFF(DAY, cast(CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as date), @EndDate) >= 0)) THEN
    DATEDIFF(DAY, cast( CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as datetime), DATEADD(d, -1, DATEADD(m, DATEDIFF(m, 0, cast( CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as datetime)) + 1, 0))) + 1
    ELSE
    0
    END as [DD]
    I don't know how you calculate day range between 01/01/2013 and 04/01/2013
    is 4, it is actually is 3 but if that is the case, you can add 1 from the condition.

  • Date from the given week nr and year

    hi to all
    With weeknr, yearnr i need to find STARTDATE (first day of the week), ENDDATE (last day of the week) The first day of the week is always a Monday.
    example 44 2007
    week nr is 44
    year is 2007
    how to find it.
    is there any standard function module to find.
    regards
    prathap

    Hello Pratap,
    Please check the function module 'VELO03_WEEK_OR_MONTH_TO_DATE'.
    I also wrote a demo program to test it.
    PARAMETER: p_week  TYPE vlc_week DEFAULT '01',
               p_gjahr TYPE gjahr.
    DATA: v_dat1 TYPE sy-datum, "Start Date
          v_dat2 TYPE sy-datum. "End Daye
    CALL FUNCTION 'VELO03_WEEK_OR_MONTH_TO_DATE'
      EXPORTING
       week_iv             = p_week
        year_iv             = p_gjahr
    IMPORTING
       date_ev             = v_dat1
    EXCEPTIONS
       week_invalid        = 1
       month_invalid       = 2
       OTHERS              = 3.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    v_dat2 = v_dat1 + 5. "Assuming Saturday is the last day
    WRITE: v_dat1, / v_dat2.
    Hope this helps. Award points if helpful.
    Thanks & Regards,
    Suhas.
    PS: You can also use the FM 'WEEK_GET_FIRST_DAY'.
    Edited by: Suhas Saha on Jan 2, 2008 8:08 AM

  • TO GET WEEKS for a given MONTH AND YEAR

    Is there any FM to get the no of weeks for a given month, say 01 2005.
    Can i get the week numbers say 1 2 3 4 5 for the given month and year.
    Please let me know.
    Happy Holidays.
    Regards,
    Manohar E

    Hi Manohar,
       Use FM DATE_GET_WEEK twice; first time pass first day of the month and again pass the last day of the month as a parameter. So u will be having week number(yyyyxx) for the first week of the month and week number for the last week of the month. From these two, in between week numbers u can easily fetch. I hope this will help u out.
    Regards,
    Kavya Shah

  • How to get the date of Friday for the given week

    HI,
    I have a requirement to get the date of Friday for the given week.
    Eg: I have an input of 200722 (Yearweek), From this I need to get the Date of the friday for this week 22 of Year 2007.
    Plz let me know how to get this..
    Thanks in advance..
    Sridhar.

    Hi,
    Thanks for your reply...
    I have implemented your logic but not getting exact output as required.
    Suppose, If i give the input as 200720, I am getting an output as 18 (friday of week 20 of year 2007), but i need to get an output of 18.05.2007
    Plz let me know how to do thdi.
    Thanks in advance..

  • How to capture the data within the given range of maximum and minimum values ? from csv files

    My requirement,
    1. Here, the user will provide the range like maximum and minimum values, based on this range, the VI should capture the data within the given range. ( from CSV file as attached )
    2. Then VI should calcluate the average value for captured data and export it to excel.
    This is my requirement can anyone help me on this.
    Many thanks in advance
    rc_cks
    Attachments:
    sample_short.csv ‏2439 KB

    Hi,
    Thanks for remnding me. I forgt to attach the VI, 
    Here I am attaching the VI, what I tried. 
    From attached CSV file, I have to find an average value for columns B,C,D,E,F,G,H,I and AJ, AK. ( data range will be defined  by user ), focused only on these columns
    Here, the scope is to calculate an average value for given data range by user as MAX and MIN data.  
    FYI:  I tried manually for two instance i.e column H & I.  As per H column one steady state values from  7500 to 10500 and similarly in I column 7875 to 10050. So, I gave these as a limit to capture and calculate the average value. But unfortunaltely, requirement has been modified as per below requirements.
    More Info on requirement: 
    --> The user will define the range of data by giving some MAXIMUM and MINIMUM values(for above mentioned columns induvidually), then VI should capture          that data range and it has to caculate the average value for that range of data. This is the task I have to complete. 
    --> I am stuck in creating a logic for data capturing for given range of MAX and MIN value from user, 
         Can anyone help me on this. 
    If my explanation is not clear, Please let me know.  
    Many thanks, help mw
    rc
    Attachments:
    VI_rc.vi ‏25 KB
    sample.zip ‏4166 KB

  • Date for a given Week

    how can i get the start date and end date for a given week
    like if i give week no. 28 then it will return the dates of the week like
    start date = 10-07-2006
    end date   = 16-07-2006.
    abhishek

    Hi,
    You can use the FM <b>GET_WEEK_INFO_BASED_ON_DATE</b>
      Import parameters               Value           
      DATE                            07/13/2006                                                                               
    Export parameters               Value           
      WEEK                            200628          
      MONDAY                          07/10/2006      
      SUNDAY                          07/16/2006      
    Regards
    vijay

  • Month for the given Week

    Can anybody tell me how to get the month for the given week..
    In my requirement I have week(201026).
    For this input, i nedd the month for this 26th week .
    Thanks in Advance.
    Moderator Message: Basic Date-related questions are not allowed since they are FAQ.
    Edited by: kishan P on Dec 17, 2010 1:17 PM

    Here's that code modified to something much more like what you specified. It prints the number of weeks between to dates inclusive, eg. there are 4 weeks between "Feb 1, 2003" and "Feb 28, 2003" not 3.something.
    I am now using the number of milliseconds in a day instead of in a week. The value 86400 is 24*60*60.
    I've also changed the input format to support days like
    June 1, 2003. Note you will need to put the args in "" when you run it because of the spaces.
    import java.util.Date;
    import java.text.*;
    public class TestTP
         static double MILLIS_PER_DAY = 86400*1000;
         public static void main( String args[ ] ) {
              double weeks;
              Date d0,d1;
              for (int i = 0; i<(args.length-1); i+=2)
                   d0 = parseDate(args);
                   if(null == d0)System.out.println(args[i]+" is bad");
                   else
                        d1 = parseDate(args[i+1]);
                        if(null == d1)System.out.println(args[i+1]+" is bad");
                        else
                             double days = dayDiff(d0,d1); // get difference in days
                             weeks = (1+days)/7;               // make it inclsive in weeks
                             System.out.println(args[i+1]+" is "+weeks+" weeks after "+args[i]+" inclusive");
         static Date parseDate(String ds)
              Date dt;
              SimpleDateFormat sdf = new SimpleDateFormat("MMM d, yyyy");
              sdf.setLenient(false);
              try{dt = sdf.parse(ds);}
              catch (ParseException e){dt = null;}
              return dt;
         static double dayDiff(Date d0, Date d1)
              return (d1.getTime()-d0.getTime())/(MILLIS_PER_DAY);

  • Cannot select a Date in the 2nd week of any month from "Month View"

    Looking for some help with a strange problem that has started within the last day or 2. In Calendar, under the Month view, it will not allow me to select a date in the current week (or the second Week dates in ANY Month for that matter i.e. 6-8-08 thru 6-14-08, 8-3-08 thru 8-9-08, 4-6-08 thru 4-12-08). It skips from the 1st week of June (6-1-08 thru 6-7-08), to the 3rd and 4th weeks of June (6-15-08 thru the end of the month). It is like it is not recognizing where my finger is pointing. I can access the current week through the list view and day view, and it will allow me to post an event by choosing the current week in the add option, but will not let me pick that date to view it once it has been scheduled. The dot shows up, and it shows on list view, but cannot get to the date by selecting it in month view. That section of my phone screen will let me access other applications and recognize where I am touching, so I don't believe it is a sensor issue. I have tried rebooting, but it has not helped. Any ideas out there? Please let me know. Thank You! for any guidance.

    Clearwater Randy,
    If the screen is only not responding in that particular application, you may want to first do a reset. To reset, press and hold the Sleep/Wake button and the Home button at the same time for at least ten seconds, until the Apple logo appears.
    If that does not resolve your issue, try restoring in iTunes. To restore, connect your iPhone into iTunes and click Restore on the Summary page. Note: All of your information will be erased from the iPhone, so make sure to have a backup of important information on your computer before restoring.
    Hope this helps,
    Jennifer B.

  • HOw to create a text file in the given path and delete it after the use?

    Hi all,
    I am trying to create a text file at the given path and delete the created file after the use.
    I am using following code.:
    import java.io.*;
    // write binary data as characters
    public class RanIO {
                                            public static void main(String f[])
                                                      // First illustrate append
                                                      String lineSep = "\n";
                                                      try {
                                                                     File temp= new File("C:/Ash","cute.txt");
                                                      boolean ch=temp.createNewFile();
                                                      if(ch)
                                                           System.out.println("file created");
                                                      else
                                                      System.out.println("file Not created");
                                                      //writing to file
                                                 /*     PrintWriter p = new PrintWriter(new BufferedWriter(new FileWriter("cute.txt",true)));
                                                      p.print("Emp NO");
                                                      p.close();*/
                                                                // Open fileWriter in append mode
                                                                               FileWriter fos = new FileWriter(temp, true);
                                                                               BufferedWriter bw = new BufferedWriter(fos);
                                                                               PrintWriter pw = new PrintWriter(fos);
                                                                               double d=550;
                                                                          // lineSep = System.getProperty("line.separator");
                                                                          pw.print("Hello");
                                                                          //pw.print( lineSep );
                                                                          pw.print( d );
                                                                          pw.close();
                                  boolean det=temp.delete();
                                                 if(det)
                                                      System.out.println("File deleted");
                                                 else
                                                      System.out.println("File not deleted");
                                                 } catch (IOException ioe)
                                                                System.out.println( "Append IO error:" + ioe );
    My problem:
    1)
    I am not able to write to the file. I want to know, where i am going wrong.
    It is giving error message like
    "Canot resolve Symbol: temp,"
    But, FileWriter Constructor should accept a File type parameter.
    here temp is a file parameter.
    If i am not using file=new file();
    i can't delete the file after the use. i.e if i use
    PrintWriter p = new PrintWriter(new BufferedWriter(new FileWriter("cute.txt",true)));
    how can i delete cute.txt after the use?
    2)
    I am not able to write to the text file. file is created but, a blank file.
    "Hello" is not written into the text file.
    can anyone help me in this regard
    Thanks in advance
    Ashvini

    Thank you Ram,
    But, i want to create a text file in Append mode.
    for that i used
    FileWriter fos = new FileWriter(temp,true); But, it is not accepting FileWriter constructor in
    this format. if i use
    FileWriter fos = new
    FileWriter("c:/ash/cute.txt",true); it works fine. !!!!!Here's the javadoc
    public FileWriter(File file,
    boolean append)
    throws IOExceptionConstructs a FileWriter object given a File object. If the second argument is true, then bytes will be written to the end of the file rather than the beginning.
    Parameters:
    file - a File object to write to
    append - if true, then bytes will be written to the end of the file rather than the beginning
    Throws:
    IOException - if the file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason
    Since:
    1.4
    Are you using jdk.13 or lower ?
    >
    ONe more doubt, Does flush method deletes a file?
    if not, then i need to use
    File temp=new File("c:/ash/cute.txt");
    FileWriter fos = new FileWriter(temp,true); //which
    is again a problem
    if(temp.delete())
    out.println("File is deleted");
    }I don't know whether i am taking it wrong ! or
    anything wrong with my coding ! but, after creating
    and writing data into a text file. I must delete it
    as it contains confidential informations.
    Regards,
    Thanks.'flush' writes to a file immediately. Else you should explicitly call 'flush' to write contents from buffer to underlying source.
    javadoc again
    PrintWriter
    public PrintWriter(Writer out,
    boolean autoFlush)Create a new PrintWriter.
    Parameters:
    out - A character-output stream
    autoFlush - A boolean; if true, the println, printf, or format methods will flush the output buffer
    cheers,
    ram.
    Question; What do you gain by opening a file, writing to it and deleting it in the same program ?

  • "Message is used to carry data between the BlackBerry handheld and an associated server"

     Hi everyone,
    I'm a first time poster!
    I've been receiving about a 100 of these emails everyday for over a week now!  
    Bell mobility and Bell ISP both say it's not their issue or problem to fix and told me to contact the other!  
    The e-mails are orginating from:
    [email protected]
    Any suggestions?
    Please help!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    This message is used to carry data between the BlackBerry handheld and an
    associated server. Please do not delete, move or respond to this message - it
    will be processed by the server.
    BEGINETP 116
    AdxV+90AAAAAIBAIMzAzQUM3MUQgGWZyaXp6ZWxsQHBlaS5zeW1wYXRpY28uY2EAI/HrYFAF
    Q01JTUUDQICAgIAyAAAwOENGOEQ3NkIrRysxALbQEVSv1zvyA8fJF15bAW0AGb/C87pyXKXe
    k+KxQN/Inek!
    ENDETP 70196029
    Message Edited by Frazzledazzle on 09-17-2009 11:44 AM

    HI and Welcome to the forums!
    Here are several KB's that discuss the issue...hopefully one of them has what you need:
    KB04254 Network@etp email messages arrive on the BlackBerry smartphone
    KB10289 What is a Network@etp message
    KB13551 Receiving both email messages and network@etp email messages on the BlackBerry Smartphone
    KB12643 ETP messages are not deleted from the Inbox after delivery to the BlackBerry smartphone
    Good luck and let us know!
    Occam's Razor nearly always applies when troubleshooting technology issues!
    If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
    Join our BBM Channels
    BSCF General Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • Any Function Module to get date by passing week and year

    Hi,
       Is there any Function Module available to get date by passing week and year. For example, Week 24, Year 2005 and you get the date.
    Regards,
    Mira

    WEEK_GET_FIRST_DAY
    pass 'YYYYWW' (200524) to WEEK parameter it will give you the week start date
    Raja

  • I have a VI and an attched .txt data file. Now I want to read the data from the .txt file and display it as an array in the front panel. But the result is not right. Any help?

    I have a VI and an attched .txt data file. Now I want to read the data from the .txt file and display it as an array in the front panel. But the result is not right. Any help?
    Attachments:
    try2.txt ‏2 KB
    read_array.vi ‏21 KB

    The problem is in the delimiters in your text file. By default, Read From Spreadsheet File.vi expects a tab delimited file. You can specify a delimiter (like a space), but Read From Spreadsheet File.vi has a problem with repeated delimiters: if you specify a single space as a delimiter and Read From Spreadsheet File.vi finds two spaces back-to-back, it stops reading that line. Your file (as I got it from your earlier post) is delimited by 4 spaces.
    Here are some of your choices to fix your problem.
    1. Change the source file to a tab delimited file. Your VI will then run as is.
    2. Change the source file to be delimited by a single space (rather than 4), then wire a string constant containing one space to the delimiter input of Read From Spreadsheet File.vi.
    3. Wire a string constant containing 4 spaces to the delimiter input of Read From Spreadsheet File.vi. Then your text file will run as is.
    Depending on where your text file comes from (see more comments below), I'd vote for choice 1: a tab delimited text file. It's the most common text output of spreadsheet programs.
    Comments for choices 1 and 2: Where does the text file come from? Is it automatically generated or manually generated? Will it be generated multiple times or just once? If it's manually generated or generated just once, you can use any text editor to change 4 spaces to a tab or to a single space. Note: if you want to change it to a tab delimited file, you can't enter a tab directly into a box in the search & replace dialog of many programs like notepad, but you can do a cut and paste. Before you start your search and replace (just in the text window of the editor), press tab. A tab character will be entered. Press Shift-LeftArrow (not Backspace) to highlight the tab character. Press Ctrl-X to cut the tab character. Start your search and replace (Ctrl-H in notepad in Windows 2000). Click into the Find What box. Enter four spaces. Click into the Replace With box. Press Ctrl-V to paste the tab character. And another thing: older versions of notepad don't have search and replace. Use any editor or word processor that does.

Maybe you are looking for