Convert AS400 integer number to a date format MM/DD/YYYY

Hi
I need a formula for converting AS400 numeric date that is in this format 1110101 CYYMMDD to this format 01/01/2011
I am using crystal reports 2008
Thanks Fred

This should do the trick...
Local StringVar x := ToText({@AC Date}, "0");
Local NumberVar c := (ToNumber(LEFT(x, 1)) + 1) * 10;
x := RIGHT(x, 6);
Local NumberVar y := ToNumber(ToText(c, "0") & LEFT(x, 2));
x := RIGHT(x, 4);
Local NumberVar m := ToNumber(LEFT(x, 2));
x := RIGHT(x, 2);
Local NumberVar d :=ToNumber(x);
Dateserial(y,m,d)
HTH,
Jason

Similar Messages

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

  • Problem with  date format "dd-MM-yyyy"

    hi all,
    i am using jdev 10.1.3.2
    My application ADF Swing app.
    in my database i have a table employee which contains "birthday".
    my problem is that i must use date format"dd-MM-yyyy".
    i added this format into "formatinfo.xml" file.
    than i choose it in my EO.
    i create a form which contains employees.
    for example i have an employee with a birthday=25-10-1970
    in my text field if user puts "1970-10-25"'which is not the best format) he will have a correct result "25-10-1970"
    but if user puts "25-10-1970" he will have as result "21-02-0031" which is not the real value.
    please help me.
    thanks.
    PS: i did some research before posting but i didn't find yet

    Rouz,
    Did you try what i said before?
    * Open you EntityObject
    * Expand the attribute tree
    * Choose your DOB attribute
    * Choose the Control hints pane on the right
    * Choose Formater: Simple date format
    * Choose Format mask dd-MM-yyyy
    Run your application and try it.
    This is how i change the format and it works perfectly.
    I uses the correct format to show the date and it enables me to edit the date using the format mask dd-MM-yyyy
    Edit: I just tried it myself. I can only reproduce it by removing my mask. Ergo, the application expects the default american format yyyy-MM-dd. By entering a date in the format dd-MM-yyyy the framework will convert it to yyyy-MM-dd and you'll end up with 0031-02-21.
    CONCLUSION follow the steps i discribed above to set your mask and you'll be fine.
    Message was edited by:
    Smolders Johan

  • How can i change the date format mm/dd/yyyy to dd/mm/yyyy

    How can i change the date format mm/dd/yyyy to dd/mm/yyyy

    Date, time and currency formats are controlled via Settings > General > International > Region Format - you can't just change the date format

  • How test the date formats  M/d/yyyy and MM/dd/yyyy .

    how test the date formats M/d/yyyy and MM/dd/yyyy .format should accept 3/3/1982 and 03/03/1982 dates.
    please help me

    georgemc wrote:
    kajbj wrote:
    Spoiler: Reply #3 is actually the answer to your question.Also, Bruce Willis is a ghost, the Titanic sinks and Verbal is Keyzer Soze.Only one of those endings really surprised me.
    You should've heard me in that theatre when the Titanic struck that iceberg...

  • Need regular expression for oracle date format 'DD-MON-YYYY'

    Hi,
    Can anybody tell me the regular expression to validate date in 'DD-MON-YYYY'.
    My concept is i have a table with just two columns item_name and item_date
    Both fields are varchar2 and i want to fetch those records from this table which have valid date format('DD-MON-YYYY').

    If it must be a regexp, this is a starter for you, note it carries the caveats mentioned by both posters above and in the linked thread
    mkr02@ORA11GMK> with data as (select '10-jan-2012' dt from dual
      2  union all select '10-111-2012' from dual
      3  union all select 'mm-jan-2012' from dual
      4  union all select '10-jan-12' from dual)
      5  select
      6  dt,
      7  case when regexp_like(dt,'[[:digit:]]{2}-[[:alpha:]]{3}-[[:digit:]]{4}','i') then 1 else 0 end chk
      8  from data
      9  /
    DT                 CHK
    10-jan-2012          1
    10-111-2012          0
    mm-jan-2012          0
    10-jan-12            0It will not validate content, only string format.
    And to emphasis the points made in the linked thread - dates in text columns is poor design. Always.

  • Convert Number to the date format

    Hello,
    In CRM, i want to input the number as a parameter and convert the number into Date format. Is there any function module in CRM which accepts the number and gives the date as output .
    Example.
    suppose input given is 734484
    output : 12-12-2011  .
    The number  734484 reflects  the total number of days from '0000' to 12-12-2011
    Regards,
    Rohini

    920575 wrote:
    I have a sql like this:
    select to_date('MAR','Mon', 'NLS_DATE_LANGUAGE=American') m from dualI want to display '3' instead of showing MAR...
    I tried to use to_char(date,'MM') but the result will return '03'.
    I would like to have the output exactly equal to 3.3 (without single-quotes) is a NUMBER. It is exactly equal to the NUMBER 03.
    '3' is a string. It is not equalt to the string '03'.
    Do you want a NUMBER or a string?
    If you want the 1-character string '3', then use 'fmMM' instead of 'MM'.
    select  TO_CHAR ( to_date ('MAR', 'Mon', 'NLS_DATE_LANGUAGE=American')
                    , 'FMMM'
                    )   AS m
    from    dualTO_CHAR sometimes adds padding (sometimes spaces, sometimes '0's) to make elements a constant width. For example, some months need 2 characters for the 'MM' format, so TO_CHAR, by default, left-pads with '0's to make all months 2 characters, whether they need 2 characters or not. Using 'FM' (case insensitive) IN the format string changes whether or not this kind of padding will be added.
    You could also use LTRIM to remove the leading '0's in this case, but why remove them when it's easier not to generate them in the first place?

  • OWB 10gR1 Convert Date format (mm-dd-yyyy) to (yyyy-mm-dd)

    Hi All,
    In OWB 10gR1, I have flatfiles with Date fields having the format (mm-dd-yyyy). I want to load this data into the Staging table in (yyyy-mm-dd) format. How could I do this conversion in my staging mapping ?
    Using external tables is not an option.
    An detailed answer will be extremely helpful.
    Thanks community.

    Wich is this field's datatype in database? Is it date or char? If you are going to store it as a date datatype, you don't have to worry about the date format.
    Have you tried using the Expression Operator to perform the date string conversion in your mapping? Sorry about this lame drawing, but I think it will help you understand:
    source_table ------------ALL_COLUMNS_EXCEPT_DATE_DATATYPE-------TARGET_TABLE
                 |                                                 |
                 +-------EXPR{TO_DATE(DATE_FIELD, 'DATE_FORMAT')}--+In this example, you'll use an expression operator to convert the date string in the format you want. Map other attributes directly to your target table (or other transformations you need to perform).
    This is the generated script of a dummy plan I've built here:
    OPTIONS ( ERRORS=50, BINDSIZE=50000, ROWS=200, READSIZE=65536)
    LOAD DATA
      CHARACTERSET WE8MSWIN1252
      INFILE '{{LOC_FILE.RootPath}}load.csv'
    INTO TABLE "LOAD_TARGET"
      APPEND
      REENABLE DISABLED_CONSTRAINTS
      FIELDS
        TERMINATED BY ';'
        OPTIONALLY ENCLOSED BY '"'
      "COD" POSITION (1) INTEGER EXTERNAL ,
    "NOME" CHAR ,
    "DATA" CHAR "to_date( :\"DATA\" , 'yyyy-mm-dd')"
      )Regards,
    Marcos

  • Convert a String to java.sql.Date Format

    Hi,
    I am having a String of containing date in the format 'dd/mm/yyyy' OR 'dd-MMM-YYYY' OR 'mm-dd-yyyy' format. I need to convert the string to java.sql.Date object so that I can perform a query the database for the date field. Can any one suggest me with the code please.
    Regards,
    Smitha

    import java.text.SimpleDateFormat;
    import java.text.ParseException;
    import java.util.Date;
    public class TestDateFormat
         public static void main(String args[])
              SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
              System.out.println(sdf.isLenient());
              try
                   Date d1 = sdf.parse("07-11-2001");
                   System.out.println(d1);
                   Date d2 = sdf.parse("07:11:2001");
                   System.out.println(d2);
              catch(ParseException e)
                   System.out.println("Error format, " + e);
    See class DateFormat and SimpleDateFormat for detail.

  • Problem with date format dd/mm/yyyy. But I need to convert yyyy-mm-dd.

    Dear friends,
    I have the problem with date format. I receiving the date with the format dd/mm/yyyy. But I can upload to MySQL only in the format of yyyy-mm-dd.
    how should I handle this situation, for this I've created these code lines.But I have some problem with these line. please help me to solve this problem.
    String pattern = "yyyy-mm-dd";
    SimpleDateFormat format = new SimpleDateFormat(pattern);
    try {
    Date date = format.parse("2006-02-12");
    System.out.println(date);
    } catch (ParseException e) {
    e.printStackTrace();
    System.out.println(format.format(new Date()));
    this out put gives me Tue Apr 03 00:00:00 IST 2007
    But I need the date format in yyyy-mm-dd.
    regards,
    maza
    thanks in advance.

    Thanks Dear BalusC,
    I tried with this,
    rs.getString("DATA_SCAD1")// where the source from .xls files
    String pattern = "yyyy-MM-dd";
    SimpleDateFormat format = new SimpleDateFormat(pattern);
    try {
    Date date = format.parse("DATA_SCAD1");
    System.out.println(date);
    } catch (ParseException e) {
    e.printStackTrace();
    System.out.println(format.format(new Date()));
    this out put gives me Tue Apr 03 00:00:00 IST 2007
    But I want to display the date format in yyyy-mm-dd.
    regards,
    maza

  • Converting date format MM/DD/YYYY to DD/MM/YYYY in ISA B2B App

    Hi All,
    We have implemented CRM ISA 5.0 (B2B) application. Is it possible to change the date format to DD/MM/YYYY in ISA B2B web application. Now currently it is showing MM/DD/YYYY in all the pages. We need to change this format to DD/MM/YYYY, where and which the date shows the current format of MM/DD/YYYY. Is there any way in XCM settings to change the date format to achieve this. Do we require custom coding ?
    Kindly suggest us!!!
    Thanks and Regards,
    Saravanan

    Hi ,
    If the sol doesn't work with the system settings, do try passing the values in char format after concatenating appropriately adding "-".
    This ll work.
          date = '02252010'. "mmddyyyy"format
          concatenate date+2(2) '-'
                      date+0(2) '-'
                      date+4(4) into var.
    var-25-02-2010dd-mm-yyyy format.
    pass the variable 'var' to the webshop/web application.

  • Converting String foramt(yyyy-mm-dd) to java.sql.Date format(mm/dd/yyyy)

    Hi,
    I am new to this Technology.
    in my Project DataBase I have the date field as String in format yyyy-mm-dd. when I am trying to fetch this date through the front-end I need to see the date in dd/mm/yyyy format of type java.sql.Date Variable.
    if you know, Pl help me.
    Thanks in Advance,
    Kamala.

    Then use a SimpleDateFormat object to parse it into a Date object, and also to format the Date the way you want to see it, rather than simply relying on the toString() implementation.

  • URGENT !!!!   Problem with Date format MM/DD/YYYY in oracle database to BW

    Hi
    I am wondering if somebody can help me urgently.
    I have oracle database where date is of the format MM/DD/YYYY and I am loading data into BW. DATE data type
    Date in oracle database: 3/30/2007
    First when I used InfoObject ZDATE (with 0DATE) reference (DATS data type) data load failed saying that
    'Value '30-MAR-0 ' of characteristic 0DATE is not a number with 000008 spaces'
    Then I created ZDATE InfoObject as CHAR Type (Length 10) with PDATE Conversion Routine.
    when I created datasource using DB Connect and checked the contents using 'Display Table Contents' after creating data source the data field distorted as
    AR/-0/30-M
    After data load. when I checked PSA
    The Date records look same as AR/-0/30-M
    In cube the field appeared as  30-MAR-0  (last digit of year disappearing)
    In BEx report also it looks like 'AR/-0/30-M'
    Can somebody help me as quickly as possible.
    What should I do if i want to still use DATS data type for ZDATE?
    should I change date format in database if so to what?
    If I should use CHAR type with PDATE or any other routine can somebody give me the routine to have the date in the report exactly as it appears in database?
    I also tried changing date format in user profile...settings. But still its the same.
    Thanks in advance.

    Hello Snrella,
    You can solve this by converting the date format from oracle to the SAP internal date format  using an ABAP routine in the transfer rules.
    Assuming the oracle data field name is ZODATE then here's the ABAP you can use in the transfer rules. Create an ABAP routine transfer rule from ZODATE to your ZDATE infoobject, and then put this ABAP code there. (this code assumes that the format of the date from oracle is MM/DD/YYYY).
    concatenate tran_structure-/BIC/ZODATE+6(4) tran_structure-/BIC/ZODATE(2) tran_structure-/BIC/ZODATE+3(2) into result.
    Hope this helps.

  • Date format dd-MMM-yyyy

    Hi Friends,
    I would be getting the date format in yyyyMMdd and i have to display it in dd-MMM-yyyy.
    I could not see suck option in 'date trans' function.
    Could some one shed somelight on this.

    Create the Simple UDF and use the below code:
    public String dateFormat(String date, Container container) { // date = yyyyMMdd convert to dd-MMM-yyyy
    if (date.length() > 0 ) {
         String [] month = {"JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"};
         char charArray[] = date.toCharArray();
         StringBuffer targetDate = new StringBuffer();
         targetDate.append(date.substring(6));
         targetDate.append("-");
         targetDate.append(month[Integer.parseInt(date.copyValueOf(charArray,4,2),10) - 1]);
         targetDate.append("-");
         targetDate.append(     date.substring(0,4));
         return targetDate.toString();
    return "";

  • Date format mm/dd/yyyy to mmddyyyy

    Hi All,
    I would like to convert the date fromat from mm/dd/yyyy to mmddyyyy.
    Actually i'm taking into a variable n checking it & concatenating it.
    But I want to know any fm for this.
    I want to know in which format the date is entering my program, if the date is coming in mmddyyyy, then I have no issues, I want to go n display in the same format.
    but if it is coming in the different i want it to b converted. mm/dd/yyyy to mmddyyyy.
    Can any body let me if there is any FM , and also let me know how to check the Date Format.
    Regards
    Rohini devi

    hi,
       WRITE : sy-datum.
       DATA : dat TYPE d.
       dat = sy-datum.
       WRITE :/ dat.
    the above mentioned code will give u output
    o/p=> 22/05/2008 -
    this is the format which u have
             22052008   -
    this is wat u wanted
    so jst assgin the variable which has value in dd/mm/yyy to a variable of type d
    reward points if useful

Maybe you are looking for

  • FF Nightly 34.0a1 keeps updating every day to the same version?!

    Ive noticed a few things this last week.. 1. first, FF Nightly (the 64bit version) has updated itself to the same version number every day for the last week.. 2. Video play using FF is terrible. 3. nightly looses my privacy settings.. 4. Some website

  • End of presentation

    At the end of my Captivate presentation, I would like the user to click on a button to exit the presentation and return to their previous application or desktop.  How is this done?  I don't see an action for 'on exit' that will work.  Please advise,

  • Output type message issue

    Hi  experts, I got an issue regarding po's output message related one here is issue : In my production system some messages(NEU) type are deleted manually (in me22n). next day to the same PO's NEU type message is sent to vendor with out physical trig

  • IPhoto importing RAW images

    Can anyone help please I have just tried to import from the card reader on my iMac some RAW images and it comes up with an error message saying it cannot read the format or the files are corrupt how can that be I thought iPhoto could deal with RAW im

  • Change flag colour in mail on iPhone

    Is it possible to change flag colour in mail on the new OS?