Converting daily date format to Calendar format 466

Hi All,
I need to convert the DAILY DATE FORMAT TO FORMAT 466...
(4 WEEKS IN PERIOD 1,6 WEEKS IN PERIOD 2 ,6 WEEKS IN PERIOD 3,
4 weeks in period 4,6 weeks in period 5,6 weeks in period 6)
I'm thinking buckets. NTILE perhaps?
But how to approach for it..???
Anyone's help will be appreciated.
Regards
Saugata

My example shows how to translate a date into what you call a "week". You'll need some fiddling to I've never heard of 466 format of weeks so it's not something that there is a pre-existing tool for. NTILE is one approach.
This gives every day in 2008 it's correct period - it's a bit messy, but then I'm only doing it to teach myself about NTILE.
with T as (
select to_date('31/12/2007','DD/MM/YYYY')+level dt
       from dual connect by level <=366)
select to_char(dt,'MM') mth, week, min(dt) start_date, max(dt) end_date from (
select  t.dt dt, NTILE(case when mod(to_char(dt,'MM'),3) = 1 then 4 else 6 end  )
                     OVER (partition by to_char(dt,'MM') order by dt asc) week
from t
) group by to_char(dt,'MM'), week
MTH     WEEK     START_DATE     END_DATE
01     1     01/01/2008     08/01/2008
01     2     09/01/2008     16/01/2008
01     3     17/01/2008     24/01/2008
01     4     25/01/2008     31/01/2008
02     1     01/02/2008     05/02/2008
02     2     06/02/2008     10/02/2008
02     3     11/02/2008     15/02/2008
02     4     16/02/2008     20/02/2008
02     5     21/02/2008     25/02/2008
02     6     26/02/2008     29/02/2008
03     1     01/03/2008     06/03/2008
03     2     07/03/2008     11/03/2008
03     3     12/03/2008     16/03/2008
03     4     17/03/2008     21/03/2008
03     5     22/03/2008     26/03/2008
03     6     27/03/2008     31/03/2008
04     1     01/04/2008     08/04/2008
04     2     09/04/2008     16/04/2008
04     3     17/04/2008     23/04/2008
04     4     24/04/2008     30/04/2008
...

Similar Messages

  • Is there any function module to convert the date format

    Dear ABAPers,
    Is there any function module to convert the date format from dd.mm.yyyy to dd-mmm-yyyy.
           I want to convert the date format from dd.mm.yyy to dd.mmm.yyy Eg.from 10.03.2008 to 10-mar-2009.
    Thanks & Regards,
    Ashok.

    hi,
    create custom function module or copy the below code in the report ..and use it
    the out put for below is :----Convert a DATE field into a full format date eg. March 23, 2000
    FUNCTION Z_CONVERT_DATE_INTO_FULL_DATE.
    ""Local interface:
    *"       IMPORTING
    *"             VALUE(DATE) LIKE  SY-DATUM
    *"       EXPORTING
    *"             VALUE(FORMATTED_DATE)
    *"       EXCEPTIONS
    *"              INVALID_DATE
    TABLES: TTDTG.
    DATA: BEGIN OF T_DATE,
            YYYY(4) TYPE C,
            MM(2) TYPE C,
            DD(2) TYPE C,
          END OF T_DATE.
    DATA: DAY(3) TYPE N.
    DATA: VARNAME LIKE TTDTG-VARNAME.
    IF DATE IS INITIAL.
      CLEAR FORMATTED_DATE.
      EXIT.
    ENDIF.
    check document date format
    CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
      EXPORTING
        DATE = DATE
      EXCEPTIONS
        PLAUSIBILITY_CHECK_FAILED = 1.
    IF SY-SUBRC NE 0.
      RAISE INVALID_DATE.
    ENDIF.
    MOVE DATE TO T_DATE.
    CONCATENATE '%%SAPSCRIPT_MMM_' T_DATE-MM INTO VARNAME.
    SELECT SINGLE * FROM TTDTG WHERE SPRAS = 'EN' AND VARNAME = VARNAME.
    WRITE T_DATE-DD TO DAY.
    CONCATENATE DAY ',' INTO DAY.
    CONCATENATE TTDTG-VARVALUE DAY T_DATE-YYYY INTO FORMATTED_DATE
      SEPARATED BY SPACE.
    ENDFUNCTION.
    the output is :--Convert a DATE field into a full format date eg. March 23, 2000
    Regards,
    Prabhudas

  • How to convert any date format to default US format using javascript???

    Hi,
    I was trying to convert a date format to default US date format. The date format will vary according to different regions (It can be dd/MM/yyyy or MM/dd/yyyy or yyyy/dd/MM or any). I need to convert it in to MM/dd/yyyy always (US Format). Please give some
    solutions for the same.
    Warm Regards,
    Tony Joy

    hi
    it is not trivial task in common case. We faced with similar issue when tried to localize date times in display templates in Sharepoint 2013 depending on site's locale, which can be done only via javascript. In order to do it you need to add date time locale
    information from server side to client side, e.g. by defining global variable. See the following article for details:
    Localize datetimes in display templates in Content by search web parts in Sharepoint 2013. I extended OTB global object _spPageContextInfo with new property (as far as I remember this object is also available in Sharepoint 2010):
    <script type="text/javascript">
    jQuery(function() {
    if (typeof (_spPageContextInfo) != "undefined" &&
    _spPageContextInfo != null) {
    <%
    var ci = new CultureInfo(1033);
    var cultureSerialized = new JavaScriptSerializer().Serialize(
    new
    name = ci.Name,
    dateTimeFormat = ci.DateTimeFormat,
    numberFormat = ci.NumberFormat
    %>
    _spPageContextInfo.currentCultureSerialized = <%= cultureSerialized %>;
    </script>
    Having different date time formats for your locale, you may use
    Date.localeFormat function from MS Ajax for formatting the date in specific format. If in your case format is predefined you may hardcode it without adding DateTime formats from server side.
    Blog - http://sadomovalex.blogspot.com
    Dynamic CAML queries via C# - http://camlex.codeplex.com

  • How to convert "any" date format to internal format

    Hi,
    I want to convert any date format  to internal format. Is there any function module ?
    The date formats could be:
    DD.MM.YYYY
    MM/DD/YYYY
    MM-DD-YYYY
    YYYY.MM.DD
    YYYY/MM/DD
    YYYY-MM-DD
    Thank you,
    Surya

    Hi,
    Check this sample program..It will convert sap supported external format to the internal format..
    PARAMETERS: v_char(10).
    DATA: v_date TYPE sydatum.
    DATA: v_period TYPE usr01-datfm.
    Get the format.
    DD.MM.YYYY
    IF v_char+2(1) = '.'.
    CONCATENATE v_char6(4) v_char3(2) v_char(2) INTO v_date.
    ENDIF.
    MM/DD/YYYY
    IF v_char+2(1) = '/'.
    CONCATENATE v_char6(4) v_char(2) v_char3(2) INTO v_date.
    ENDIF.
    MM-DD-YYYY
    IF v_char+2(1) = '-'.
    CONCATENATE v_char6(4) v_char(2) v_char3(2) INTO v_date.
    ENDIF.
    YYYY.MM.DD
    IF v_char+4(1) = '.'.
    CONCATENATE v_char(4) v_char5(2) v_char8(2)  INTO v_date.
    ENDIF.
    YYYY/MM/DD
    IF v_char+4(1) = '/'.
    CONCATENATE v_char(4) v_char5(2) v_char8(2)  INTO v_date.
    ENDIF.
    YYYY-MM-DD
    IF v_char+4(1) = '-'.
    CONCATENATE v_char(4) v_char5(2) v_char8(2)  INTO v_date.
    ENDIF.
    WRITE: / v_date.
    Thanks,
    Naren

  • How To Convert Incomming Date Format  to Our Own Format

    Hi All,
    My Sceario is File XI-File
    My Incoming File is Having the Date With Some DD.MM.YYYY
    But I Want to Convert that Date Format to YYYY MM DD
    So What i have to Do For this
    Regards
    Vamsi

    Hi u can create USD define function
    sample code
    String DB;
    DB=DOB.substring(8,10)"/"DOB.substring(5,7)"/"DOB.substring(1,4);
    return DB;
    or else u can use DateTrans from ur standard function.
    right click -> properties -> give the date format
    regards
    yugapreetha
    Message was edited by:
            Yugapreetha T

  • Problem in converting legacy date format

    Hello all,
    I am having a legacy file in which the date format is yyddd (  e.g  07129 ).
    Can any of you experts suggest me how can i convert these date format in SAP date format i.e YYYYMMDD.
    Please  suggest.
    Arun

    Hi, Arun
    May be the following code will help you in this way,
    data: date like sy-datum,
          year(4),
          month(2),
          day(2).
    year = '2006'.
    month = '12'.
    day = '01'.
    date+0(4) = year.
    date+4(2) = month.
    date+6(2) = day.
    Replay if any problem,
    Kind Regards,
    Faisal
    Edited by: Faisal Altaf on Jan 6, 2009 11:00 PM

  • Need to convert into date format

    Hi all,
    I need to convert '2008-11-26T11:07:38-06:00' [YYYY]-[MM]-[DD]T[HH]:[MM]:[SS][TIMEZONE]
    in format 'YYYY-MM-DD HH:MM:SS'.
    Thanks in advance.

    >
    Thank you for your reply
    But it is giving me output as '26-NOV-08'
    And I want in format '2008-11-26 07:38' i.e 'YYYY-MM-DD HH:MM'.
    >
    Then you are not looking for a date, You are looking for a string.
    The date format that gets displayed is dependent on nls_date_format parameter.
    If you want a string in the format you asked, then,
    SELECT TO_CHAR ( TO_DATE ( '2008-11-26T11:07:38-06:00', 'YYYY-MM-DD"T"HH24:MI:SS"-06:00"'), 'YYYY-MM-DD HH24:MM:SS')
      FROM DUAL;Or if you just want the date to be displayed like that then
    Do,
    SQL> alter session set nls_date_Format="YYYY-MM-DD HH24:MI:SS";
    Session altered.
    SQL> SELECT TO_DATE ( '2008-11-26T11:07:38-06:00', 'YYYY-MM-DD"T"HH24:MI:SS"-06:00"') dt
      2    FROM DUAL;
    DT
    2008-11-26 11:07:38
    SQL> G.

  • How to convert the date format 'm/d/yyyy hh:mi:ss AM' to 'MM/DD/YYYY HH:M'

    How can i convert a the date format 'm/d/yyyy hh:mi:ss AM' to 'MM/DD/YYYY HH:MI:SS AM' in Oracle
    I have a query
    select UPPER(t.val_10) "TYPE", count(val_3) "Number of Transfers"
    from table1 t
    where t.is_active = 1
    and t.val_4 = 'INBOUND'
    and to_date(to_date(val_5,'MM/DD/YYYY HH:MI:SS AM'), 'DD/MM/YY') between to_date(to_date('01/08/2008 00:00:00','DD/MM/YYYY HH24:MI:SS'), 'DD/MM/YY') and add_months(to_date(to_date('01/08/2008 00:00:00','DD/MM/YYYY HH24:MI:SS'), 'DD/MM/YY'),1)
    group by UPPER(t.val_10)
    order by UPPER(t.val_10)
    I get the error [ORA-01861: literal does not match format string which i think is because
    val_5 has the values in the following format:
    8/29/2008 6:31:10 PM
    Does anyone have an answer?
    Thanks in advance
    Edited by: user2360027 on 26-Mar-2009 03:50                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    first off, you've got to_date(to_date(...)) - NEVER do this - you're forcing an implicit to_char which can cause all sorts of problems!
    What is the data type of your column val_5? If it's DATE then your query is simply:
    select UPPER(t.val_10) "TYPE",
           count(val_3) "Number of Transfers"
    from   table1 t
    where  t.is_active = 1
    and    t.val_4 = 'INBOUND'
    and    val_5 between to_date('01/08/2008','DD/MM/YYYY') and add_months(to_date('01/08/2008','DD/MM/YYYY') ,1)
    group by UPPER(t.val_10)
    order by UPPER(t.val_10)If it's a varchar2 (why, oh why, oh why, ...?!), then your query should be:
    select UPPER(t.val_10) "TYPE",
           count(val_3) "Number of Transfers"
    from   table1 t
    where  t.is_active = 1
    and    t.val_4 = 'INBOUND'
    and    to_date(val_5, 'mm/dd/yyyy hh:mi:ss AM') between to_date('01/08/2008','DD/MM/YYYY') and add_months(to_date('01/08/2008','DD/MM/YYYY') ,1)
    group by UPPER(t.val_10)
    order by UPPER(t.val_10)Remember that dates in DATE format are stored in an internal Oracle format - in order for you to tell Oracle that your string is a date, you need to use to_date. When you want to retrieve a date, you need to use to_char to put it into the format you want to see it in.
    Remember also that your nls_date_format defines the default format that you'll see a date, which is what is used in the implicit conversion that oracle does when you select a date:
    SQL> alter session set nls_date_format='dd/mm/yyyy hh24:mi:ss';
    Session altered.
    SQL> select sysdate from dual;
    SYSDATE
    26/03/2009 11:01:53
    1 row selected.
    SQL> alter session set nls_date_format='mm/dd/yy hh12:mi:ss AM';
    Session altered.
    SQL> select sysdate from dual;
    SYSDATE
    03/26/09 11:02:24 AM
    1 row selected.It doesn't make sense to convert something that's already in a DATE format into a DATE format - in order to do that, oracle has to first change the date into a string, and it does that by using the nls_date_format parameter setting - if you're working with dates-in-strings that are in a different format, then all sorts of problems arise, as you have found out!

  • Convert Oracle date format masks to Java format masks

    Have an application based on Oracle that stores data in text form (for display) and in native date format. It is being migrated to another application with a Java based front end that can only use Java format masks to display the dates in the desired display format.
    Is there a way to translate the Oracle format masks to Java? I can do this in SQL or PL/SQL using the database or in Java.
    I really don't want to write detailed code to parse the masks, although if parsers are available to take an oracle mask into its metadata (minute, year, etc), it may be possible for me to write the code.
    This seems like something that must have been done many times over the years. I would prefer to reuse workable code rather than reinventing the wheel.
    To be clear, I do not need to alter data or convert dates shown in string form. Just the format masks so the new app will display dates in the same manner as the old app. Fortunately, both apps handle interpreting the format masks in their native technology, so it is just converting the format mask.

    kenmadsen wrote:
    Both applications have a varchar2 column and a date column. A date picker selects and returns the date in native format for storage and the application uses the mask to format the varchar2 column for display (and storage). The old application uses an Oracle date format mask DD-Mon-YYYY HH24:MI and the new application uses Java date masks (DD-MM-YYYY hh:mm). (I may not have the translation from HH24 to hh correct).
    The date column and the display column store the same information (a date), but one is stored natively and the other is displayed as the application administrator want the particular row to be formatted for display. (the mask is a column in the same table as the other 2 columns). Each row has characteristics (other columns) that determines what the data is and how it should be shown (some things need to show time; others only the date)
    So the problem is, when migrating, the new application cannot render the dates as the old app did because "Mon" is Oracle format, not Java format.
    No data is being converted in the migration, except for the mask itself. Both applications have the same record structure with respect to these columns and they both use the mask to generate the formatted varchar2 data for display in the application and storage.too bad you insist on try to describe with words rather than actual CODE.
    Please explain again why this is an Oracle problem & NOT a Java problem?
    Oracle RDBMS is a data repository & can't automagically change data content for you.

  • How to convert any date format?

    Hi,
    In the BPEL process I am getting the input in 'DD-MON-YYYY' format, I want to convert it to 'DD-MM-YYYY' format.
    The function xp20:formatDateTime('string', 'image') expecting the string to be in 'YYYY-MM-DD' format. and the 'image' can be set to any format.
    So i am able to convert to any format if I have the input string in 'YYYY-MM-DD' format, if I get in different format then how do I change them to required format?
    --Khaleel                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Looks like you are sending the date in Oracle format. If the date is created by a DB adapter the date should be formated in the correct format for BPEL to format (YYYY-MM-DDTHH:MI:SS). To make sure this happensyour xml needs to be the date data type and the value sent maust be a date not a string, if it is a string use the to_date to make it a date field.
    You are correct once it is in the YYYY-MM-DD format you can change to any format.
    cheers
    James

  • Convert yyyymmdd date format to mm/dd/yyyy

    hi,
    I convert the date fomat in my program from yyyymmdd to dd/mm/yyyy format using this code:
    WRITE it_pos-bldat TO i_outpos-bldat MM/DD/YYYY.
    I declared the bldat field by: bldat(10) TYPE c so that the field will contain the '/' character.
    The output of my program is in alv format and the problem is when I sort the bldat field, it will be sorted as a character field and not by date.
    Ex. 01/06/2005
        02/23/2004
        03/12/2006
        04/09/2004
    It should be sorted like this:
    02/23/2004
    04/09/2004
    01/06/2005
    03/12/2006
    Please let me know how I can convert into mm/dd/yyyy format and can still be sorted in the alv by date.
    Thanks!
    Eric

    <b>HRGPBS_HESA_DATE_FORMAT</b>
    Format a date valid for HESA: DD/MM/YYYY
    data:date_form type CHAR10.
    call function 'HRGPBS_HESA_DATE_FORMAT'
    exporting
    P_DATE = sy-datum
    importing
    DATESTRING = date_form
    exceptions
    others = 1.
    write : date_form.
    also check thread..
    Re: Regarding Date conversion

  • Accepting date in JTextField and converting to date format

    I'm trying to convert JTextField value to date format but I can't. I need to send date value to a date field of database. Could anyone help me convert JTextField value to Date value?
    Thanks

    Date SimpleDateFormat.parse(String) ?

  • String conversion gives error when converting to date format

    Hello,
    I need to convert a character to a date format. The character string is 201053131415151 where the first eight characters represent YYYYMMDD. The string may also be null ( second value). I used the following select statement
    select distinct sysdate "Run Date",
    rcreviewdate "Review Date",
    nvl((to_char(substr(rcreviewdate,1,8))),'None') "Review Date2"
    and got the following result.
    Run Date Review Date Review Date2
    30-NOV-09 201005131415151 20100513
    30-NOV-09
    1. Why is "None" not returned for the secord valule which is null?
    2. How can the valule "20100513" be converted to DD-MON-YY ( the date format)?
    to_date(substr(rcreviewdate,1,8),'YYYYMMDD') gives the following error with the null value
    Error report:
    SQL Error: ORA-01841: (full) year must be between -4713 and +9999, and not be 0
    01841. 00000 - "(full) year must be between -4713 and +9999, and not be 0"

    Hi,
    PANY wrote:
    1. Why is "None" not returned for the secord valule which is null?
    2. How can the valule "20100513" be converted to DD-MON-YY ( the date format)?
    to_date(substr(rcreviewdate,1,8),'YYYYMMDD') gives the following error with the null value
    Error report:
    SQL Error: ORA-01841: (full) year must be between -4713 and +9999, and not be 0
    01841. 00000 - "(full) year must be between -4713 and +9999, and not be 0"Are you sure reviewdate is NULL, and not a string consisting only of spaces or tabs?
    TO_DATE will return NULL if its 1st argument is NULL, so it looks like reviewdate is not NULL.
    You can use LTRIM (among other functions) to remove spaces from reviewdate, if that's the problem.
    Post a little sample data (CREATE TABLE and INSERT statements), and the results you want from that data.

  • Converting odd date format to another format

    Hey all,
    I have a date format that looks like this: "2006-08-29T00:00:00.000Z"
    so i have written this code:
    DateFormat dFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss:SSSZ");when i try to do
    dFormat.parse("2006-08-29T00:00:00.000Z");i get this: java.text.ParseException: Unparseable date: "2006-08-29T00:00:00.000Z"
    Does anyone know what i am doing wrong?

    I'm still getting it:
    Here's my code now:
    String temp = "2006-08-29T00:00:00.000Z";
             DateFormat dFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss:SSS'Z'");
             try {
                   dFormat.parse(temp);
              } catch (ParseException e1) {
                   // TODO Auto-generated catch block
                   e1.printStackTrace();
              }

  • Problem in converting util date format to sql date format

    im trying to convert util date to sql date...i'm getting the error msg as
    Error is : java.lang.NullPointerException
    Error Message : null
    i'm not bale to track the result...whatz the problem with this code?
    This fromDate value will be dynamically built, value will be
    fromDate="Tue Jul 15 00:00:00 IST 2003";
    java.util.Date xx=util.stringToDate(fromDate);
    java.sql.Date sqlD=null;
    sqlD.setTime(xx.getTime());
    System.out.println("sqld"+sqlD);

    I try this and it works:
    SimpleDateFormat simpledateformat = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy", Locale.UK);
    String s = "Tue Jul 15 00:00:00 IST 2003";
    java.util.Date date = simpledateformat.parse(s);
    java.sql.Date sqlD=new java.sql.Date(date.getTime());
    System.out.println("sqld"+sqlD);
    Hope this helps.

Maybe you are looking for

  • Text messages on Macbook pro

    How do I get text messages from my phone to my macbook pro?

  • Problem with IDX2

    HI All ,        I am doing a IDOC --> XI --> File scenario , i have created RFC destination and created port in IDX1 , when i try to load metadata in IDX2 i am geting a information window with message "<b>I::000</b>" . i have tested my RFC destinatio

  • Can Audigy 2 ZS Platinum Record in 24/96 or N

    The documentation says it can but I haven't found a way to do it yet. I've tried the Audigy included software, Audition and Goldwave. Looking at the spectral's in Audition the wavs seem to be resampled to 48kHz or less. I'm using the analog inputs (R

  • How can I "reprompt" when a OBIEE request has been imported into powerpoint

    Hi All, How can I "reprompt" when a OBIEE request has been imported into powerpoint using the Oracle Bi plugin for microsfot powerpoint? When you import a request into powerpoint it show the prompts you have defined in yout request. How can the user

  • How to Create a LiveTrace Options Script

    Hello everyone! I am using Illustrator CS3 on WinXP Pro. Let me begin by saying that this is my first attempt at scripting anything and any help would be truly appreciated. I have written a script: var myDocument = app.activeDocument; var mySelection