UDF for Date format

Hi,
I want to write an UDF
I want to pass Date as an String in format yyyymmdd.
I want to convert it to mm/dd/yyyy. & pass new date as o/p/
But there is a possibility that i/p Date may come as blank in that case I want to keep output as blank.
Please help

Thanks guys,
I am using this code but get an error
int len;
len = Date.length();
if (len>7)
String year = Date.substring (0,4);
String month = Date.substring (4,2);
String day = Date.substring (6,2);
String f  = month + "/" + day + "/" + year;
return f;
else
return Date;
--- Here when I run this in test mode I get this exception -
Exception:[java.lang.StringIndexOutOfBoundsException: String index out of range: -2] in class com.sap.xi.tf._MM_PSN_EMP_INFO_ method check$[19880517, B1, A1, C1, F1, G1, H1, X1, X1, X1, X1, X1, X1, 07, 5, com.sap.aii.mappingtool.tf3.rt.Context@7ab97403]
Please help.

Similar Messages

  • Input Value long enough for date format ,Error in executing parallel query

    Hi,
    My Table: ANML( ID, STATUS,B_DATE,B_MONTH,B_YEAR, DEATH_DATE)
    status 1 for alive and 2 for dead.
    i wrote a view to get age.
    as
    create or relace view view1 as
    select top."ID",top."STATUS",top."DOB",top."DEATH_DATE",top."ANML_AGE",top."DAYSDIFF",
    CASE
    WHEN anml_age < 1
    THEN 'D'
    ELSE 'M'
    END age_unit,
    CASE
    WHEN anml_age < 1
    THEN TO_CHAR (daysdiff || ' Day(s)')
    WHEN anml_age < 12
    THEN TO_CHAR (anml_age || ' Month(s)')
    WHEN MOD (anml_age, 12) = 0
    THEN TO_CHAR (ROUND (anml_age / 12, 0) || ' Year(s) '
    ELSE TO_CHAR ( ROUND (anml_age / 12, 0)
    || ' Year(s) '
    || MOD (anml_age, 12)
    || ' Month(s)'
    END age_string
    from
    (SELECT a.*,
    CASE WHEN status IN ( 1)
    THEN FLOOR(MONTHS_BETWEEN(TRUNC(SYSDATE),dob))
    WHEN death_date IS NOT NULL AND status IN (2)
    THEN FLOOR(MONTHS_BETWEEN(death_date,dob))
    END anml_age,
    CASE WHEN status IN (1)
    THEN FLOOR(TRUNC(SYSDATE)-TRUNC(dob))
    WHEN death_date IS NOT NULL AND status IN (2)
    THEN FLOOR(TRUNC(death_date) - TRUNC(dob))
    END daysdiff
    from (
    SELECTanml.id, status,
    TO_DATE ( DECODE (b_date,
    NULL, 1,
    b_date
    || '-'
    || DECODE (b_month,
    NULL, 1,
    b_month
    || '-'
    || b_year,
    'dd-mm-yyyy'
    ) DOB,
    death_date
    FROM anml
    WHERE b_year IS NOT NULL
    ) a) top
    when i tried to fetch all values from view its working fine.
    But when i tried to fetch values based on condition like as follows,
    select * from view1 where anml_age > 20 and anml_age<30
    I am getting error like:
    Input Value long enough for date format and Error in executing parallel query
    Please tell me wht is wrong.

    Here is your formatted code
    create or relace view view1 as
    select top."ID",top."STATUS",top."DOB",top."DEATH_DATE",top."ANML_AGE",top."DAYSDIFF",
    CASE
    WHEN anml_age < 1
    THEN 'D'
    ELSE 'M'
    END age_unit,
    CASE
    WHEN anml_age < 1
    THEN TO_CHAR (daysdiff || ' Day(s)')
    WHEN anml_age < 12
    THEN TO_CHAR (anml_age || ' Month(s)')
    WHEN MOD (anml_age, 12) = 0
    THEN TO_CHAR (ROUND (anml_age / 12, 0) || ' Year(s) '
    ELSE TO_CHAR ( ROUND (anml_age / 12, 0)
    || ' Year(s) '
    || MOD (anml_age, 12)
    || ' Month(s)'
    END age_string
    from
    (SELECT a.*,
    CASE WHEN status IN ( 1)
    THEN FLOOR(MONTHS_BETWEEN(TRUNC(SYSDATE),dob))
    WHEN death_date IS NOT NULL AND status IN (2)
    THEN FLOOR(MONTHS_BETWEEN(death_date,dob))
    END anml_age,
    CASE WHEN status IN (1)
    THEN FLOOR(TRUNC(SYSDATE)-TRUNC(dob))
    WHEN death_date IS NOT NULL AND status IN (2)
    THEN FLOOR(TRUNC(death_date) - TRUNC(dob))
    END daysdiff
    from (
    SELECTanml.id, status,
    TO_DATE ( DECODE (b_date,
    NULL, 1,
    b_date
    || '-'
    || DECODE (b_month,
    NULL, 1,
    b_month
    || '-'
    || b_year,
    'dd-mm-yyyy'
    ) DOB,
    death_date
    FROM anml
    WHERE b_year IS NOT NULL
    ) a) top

  • Class Cast Exception for Date Format .

    Hi Friends ,
    I am getting a error for casting type from Object to Date type .
    Could you please some one help me . I am using a prepared statement in OAF for inserting a data .
    All fields are inserting except Date format .
    My code in controller as follows :
    try {    String StartDate=row.getAttribute("StartDate").toString();
    // String StartDate="30-Apr-2011";
    DateFormat formatter ;
    Date StartDate1;
    formatter = new SimpleDateFormat("dd-MMM-yy");
    StartDate1 = (Date)formatter.parse(StartDate);
    //System.out.println("Today is " +date );
    pstmt.setDate(12,StartDate1);
    } catch (ParseException e)
    {System.out.println("Exception :"+e);    }
    Thanks in Advance ,
    Keerthi

    Thanks so Much for the quick response .
    Exception Details.
    oracle.apps.fnd.framework.OAException: java.lang.ClassCastException at oracle.apps.fnd.framework.OAException.wrapperException(OAException.java:888) at oracle.apps.fnd.framework.webui.OAPageErrorHandler.prepareException(OAPageErrorHandler.java:1145) at oracle.apps.fnd.framework.webui.OAPageErrorHandler.processErrors(OAPageErrorHandler.java:1408) at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(OAPageBean.java:2637) at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1659) at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:497) at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:418) at OA.jspService(OA.jsp:40) at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56) at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:317) at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:465) at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:379) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:727) at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306) at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:767) at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:259) at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:106) at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:803) at java.lang.Thread.run(Thread.java:534) ## Detail 0 ## java.lang.ClassCastException at SONY.oracle.apps.inv.xx_slapg.webui.ServiceRequestCO.processFormRequest(ServiceRequestCO.java:153) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:799) at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:363) at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processFormRequest(OAPageLayoutHelper.java:1118) at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processFormRequest(OAPageLayoutBean.java:1579) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:995) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:961) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:816) at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:363) at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processFormRequest(OAFormBean.java:395) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:995) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:961) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:816) at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:363) at oracle.apps.fnd.framework.webui.beans.OABodyBean.processFormRequest(OABodyBean.java:363) at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(OAPageBean.java:2633) at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1659) at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:497) at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:418) at OA.jspService(OA.jsp:40) at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56) at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:317) at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:465) at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:379) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:727) at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306) at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:767) at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:259) at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:106) at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:803) at java.lang.Thread.run(Thread.java:534) java.lang.ClassCastException at SONY.oracle.apps.inv.xx_slapg.webui.ServiceRequestCO.processFormRequest(ServiceRequestCO.java:153) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:799) at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:363) at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processFormRequest(OAPageLayoutHelper.java:1118) at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processFormRequest(OAPageLayoutBean.java:1579) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:995) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:961) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:816) at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:363) at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processFormRequest(OAFormBean.java:395) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:995) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:961) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:816) at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:363) at oracle.apps.fnd.framework.webui.beans.OABodyBean.processFormRequest(OABodyBean.java:363) at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(OAPageBean.java:2633) at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1659) at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:497) at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:418) at OA.jspService(OA.jsp:40) at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56) at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:317) at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:465) at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:379) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:727) at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306) at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:767) at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:259) at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:106) at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:803) at java.lang.Thread.run(Thread.java:534)
    Here is my code .
    java.util.Date StartDate=(java.util.Date)row.getAttribute("StartDate");
    ------------------------------------------------------------------------------------------------

  • Parsing Issue in Filter For Date Format

    Hi Folks,
    I am having Parsing Issue on "Key Date" Object in Universe. See the Error and Code below for your review
    Error: Parse Failed: Exception: DBD, The value entered is not valid. It must adhere to one of the following formats.
    YYYYMMDD
    DD.MM.YYYYState:N/A
    Code:
    <OPERATOR VALUE="AND"><OPTIONAL><FILTER KEY="0I_DAYIN"><CONDITION OPERATORCONDITION="Between"><CONSTANT TECH_NAME="@Prompt('Day Interval From','A','Calendar Day\LovDay IntervalBase',mono,primary_key)"/><CONSTANT TECH_NAME="@Prompt('Day Interval To','A','Calendar Day\LovDay IntervalBase',mono,primary_key)"/></CONDITION></FILTER></OPTIONAL><FILTER KEY="0P_KEYDA"><CONDITION OPERATORCONDITION="Equal"><CONSTANT TECH_NAME="@Prompt('Key Date','D',,mono,free)"/></CONDITION></FILTER></OPERATOR>
    This universe is created by someone else and client need to modify it with a calendar but i did not modify it yet however its already giving me the hard time. Kindly advise, any kind of help will be appreciated
    Thanks

    Hi,
    With the information provided I cannot for sure get to the error but here is what I would check.
    Firstly, I was wondering if the 5th parameter in the @Prompt can be Primary_Key. I thought it would be either free or constrained.
    Secondly, please the LOV values for the @ prompt are being populated from 'Calendar Day\LovDay IntervalBase'. So I would check the date format being used there.
    Third, the To and From dates are alphaneumeric and not dates, so I am not sure how the comparision would happen.
    Hope this helps.
    Regards,
    Madhur

  • Sum values in last row for date format "hh24:mi"

    Hi,
    I have a big problem creating a sum row with date data.
    I created a sql view where the result looks like that:
    SELECT category_name,
    user_name,
    b_mmyyyy,
    b_1, ..., b_31
    FROM view_category_user_booking
    category_name, user_name, b_1, ..., b_31
    category1, user1, 122008, 01:00, ..., 03:30
    category2, user1, 122008, 02:00, ..., 01:00
    category3, user1, 122008, 00:00, ..., 00:15My goal is to integrate a sum row at the end for the columns b_1 ... b_31
    category_name, user_name, b_1, ..., b_31
    category1, user1, 122008, 01:00, ..., 03:30
    category2, user1, 122008, 02:00, ..., 01:00
    category3, user1, 122008, 00:00, ..., 00:15
    Sum, user1, 122008, 03:00, ..., 04:45I tried it like that:
    select decode(grouping(category_name),1,'Summe',category_name),
    sum(to_number(replace(b_1,':',','))) as b_1,
    sum(to_number(replace(b_31,':',','))) as b_31
    from category_user_booking
    where user_name = 'user1'
    and b_mmyyyy = '122008'
    group by rollup(category_name)But the result isn't really successful
    category_name, b_1, b_31
    category1, 1, 3,3
    category2, 2, 1
    category3, 0, 0,15
    Sum, 3, 4,45Is there somebody with an idea?
    Thanks ahead,
    Tobias

    Hi Avinash,
    the problem is not the grouping it is the date format.
    Instead of a value like 5,4 > I want 05:40 or 1,75 > I want 02:15 in the sum value.
    In my table all time values are saved in the format hh24:mi.
    I don't know how to get that via a sql statement.
    Output I want:
    category_name, user_name, b_1, ..., b_31
    category1, user1, 122008, 01:00, ..., 03:30
    category2, user1, 122008, 02:00, ..., 01:00
    category3, user1, 122008, 00:00, ..., 00:15
    Sum, user1, 122008, 03:00, ..., 04:45Regards,
    Tobias

  • Validating JTextField for Date Format

    hello,
    everybody.
    i am trying to perform a validation on text field, i.e if the input is in a date format then it will show, other wise it will consume the character.
    please help me out of this problem i am stucked with it.
    waitng for reply. the following is my code.
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    import java.util.*;
    import java.text.*;
    public class RilJDateField implements KeyListener
         JFrame frame;
         JPanel panel;
         JLabel label;
         JTextField text;
         GridBagLayout gl;
         GridBagConstraints gbc;
         Date date = new Date();
         public static void main(String a[])
              new RilJDateField();
         public RilJDateField()
              panel = new JPanel();
              gl = new GridBagLayout();
              gbc = new GridBagConstraints();
              panel.setLayout(gl);
              label = new JLabel("Only Date Format");
              text = new JTextField(5);
              gbc.anchor = GridBagConstraints.NORTHWEST;
              gbc.gridx = 1;
              gbc.gridy = 1;
              gl.setConstraints(label,gbc);
              gbc.anchor = GridBagConstraints.NORTHWEST;
              gbc.gridx = 2;
              gbc.gridy = 1;
              gl.setConstraints(text,gbc);
              panel.add(label);
              panel.add(text);
              text.addKeyListener(this);
              text.requestFocus();
              frame = new JFrame("RilJDateField Demo");
              frame.getContentPane().add(panel);
              frame.addWindowListener(new WindowAdapter() {
                        public void windowClosing(WindowEvent we)
                             System.exit(0);
              frame.setSize(300,300);
              frame.setVisible(true);
         public void keyTyped(KeyEvent ke)
         public void keyPressed(KeyEvent ke)
              DateFormat df;
              df = DateFormat.getDateInstance();
              df = (DateFormat) ke.getSource();
              if(!(df.equals(date)))
                   ke.consume();
         public void keyReleased(KeyEvent ke)
    }

    hi,
    thanks very much, u gave me great idea.
    according to ur suggestion i used JFormattedTextField as well as SimpleDateFormat, but while giving keyevent i am getting the error,
    so please if possible reply for this.
    the error is
    java.lang.ClassCastException
         at RilJDateField.keyTyped(RilJDateField.java:61)
         at java.awt.Component.processKeyEvent(Unknown Source)
         at javax.swing.JComponent.processKeyEvent(Unknown Source)
         at java.awt.Component.processEvent(Unknown Source)
         at java.awt.Container.processEvent(Unknown Source)
         at java.awt.Component.dispatchEventImpl(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source)
         at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source)
         at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Source)
         at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source)
         at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)
         at java.awt.Component.dispatchEventImpl(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Window.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.EventQueue.dispatchEvent(Unknown Source)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.run(Unknown Source)and my source code is
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    import java.util.*;
    import java.text.*;
    public class RilJDateField implements KeyListener
         JFrame frame;
         JPanel panel;
         JLabel label;
         JFormattedTextField text;
         GridBagLayout gl;
         GridBagConstraints gbc;
         Date date = new Date();
         SimpleDateFormat formatter;
         public static void main(String a[])
              new RilJDateField();
         public RilJDateField()
              panel = new JPanel();
              gl = new GridBagLayout();
              gbc = new GridBagConstraints();
              panel.setLayout(gl);
              label = new JLabel("Only Date Format");
              text = new JFormattedTextField();
              text.setColumns(10);
              formatter = new SimpleDateFormat("dd mm yyyy");
              gbc.anchor = GridBagConstraints.NORTHWEST;
              gbc.gridx = 1;
              gbc.gridy = 1;
              gl.setConstraints(label,gbc);
              gbc.anchor = GridBagConstraints.NORTHWEST;
              gbc.gridx = 2;
              gbc.gridy = 1;
              gl.setConstraints(text,gbc);
              panel.add(label);
              panel.add(text);
              text.addKeyListener(this);
              text.requestFocus();
              frame = new JFrame("RilJDateField Demo");
              frame.getContentPane().add(panel);
              frame.addWindowListener(new WindowAdapter() {
                        public void windowClosing(WindowEvent we)
                             System.exit(0);
              frame.setSize(300,300);
              frame.setVisible(true);
         public void keyTyped(KeyEvent ke)
              Date date = (Date) ke.getSource();
              if(!(date.equals(formatter)))
                   ke.consume();
         public void keyPressed(KeyEvent ke)
         public void keyReleased(KeyEvent ke)
    }

  • NEED ALTER TABLE ALTER COLUMN FOR DATE FORMAT

    Need something like this :
    ALTER TABLE ABC
    ALTER COLUMN DATE1 AS (DD/MM/YYYY)
    need to appear in this format (29/03/2014) in the table.
    also needs to be recorded in DB in that format.

    changed system date format, works. Thanks!
    You should always store values as dates itself in date/datetime related field in SQLServer
    The formatting can very easily be done in your front end (presentation layer) using format function
    Even in T-SQL you can use CONVERT or FORMAT functions to get the date values in the format you want
    Please Mark This As Answer if it solved your issue
    Please Mark This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page
    I don't follow you? Anyway, Olaf Helper's answer was the solution.
    SQL Server has a data type called DATETIME. To correctly query dates, it is easier to use this as it allows the SQL engine to do all the calculations for you, also the canonical format for dates in any database language is YYYY-MM-DD, this ensures correctly
    tiered dates that are stored in the right order. The way you store data and the way you display it should be kept as two seperate entities. This is the ISO standard and has been thoroughly investigated ...alot to say the least. This is where the term "front-end"
    and "back-end" developers come from, and also the distinction between server-side and client-side scripting.
    To cut a long story short, take the advice of the multiple professionals here, and follow standards otherwise you'll find yourself stuck, or worse, your legacy code will make someone tear their hair out.

  • Obiee 11g upgrade issue for date format

    Hi,
    I am facing a date format issue with obiee 11g report. This statement cast(cast(current_date as char) as timestamp) is failing with "not a valid month" error in obiee 11g. This worked fine with obiee 10g.
    I am basically trying to set the date to 12:00:00 am of the sysdate. Below is what I am trying to achieve:
    timestampadd(sql_tsi_hour, 1, cast(cast(current_date as char) as timestamp)))
    the above statement fails in obiee 11g.
    Thanks for your help,
    AP

    I dont think you need any functions to get the required output, try to set the date format as below
    [FMT:timeStampShort]
    If helps mark
    Thanks
    Edited by: Srini VEERAVALLI on Apr 23, 2013 4:18 PM
    I think with format and then the below should work with no issues.
    timestampadd(sql_tsi_hour, 1,current_date)
    I think you are wasting time by posting here, just do it. You no need any ones permissions to do it ;)
    Edited by: Srini VEERAVALLI on Apr 24, 2013 8:55 AM

  • FM For date Format

    Hi,
    Could anybody assist me, the date format is like 20080519, but it should be in the format of 19.05.2008.Is there any function module .
    Thanks in advance.
    Regards.
    I.Reddy Prasad.

    Hi,
    CALL FUNCTION 'CONVERT_DATE_TO_INTERN_FORMAT'
        EXPORTING
          DATUM = W_DATE1
          DTYPE = 'DATS'
        IMPORTING
          IDATE = W_DATE2.
    Month in words
    Date Format (month in words, day and year in number)
    Regards
    Adil

  • Function module for date format

    Hi,
    what is the function module name to get the date format in <b>(dd.mm.yyyy)</b> from (<b>dd-mon-yyyy)</b>
    Thanx.

    try this Fm
    CONVERSION_EXIT_SDATE_INPUT
    input as dd-mon-yyyy
                28FEB2007
    im assuming mon in literal format.
    output is 20070228
    WRITE STATEMENT WILL DISPLAY THE DATA IN DEFALUT DATE FORMATS OF SU3 .
    <b>Elaborate teh query with an example .</b>
    check this
    regards,
    vijay.

  • How to declare data type for DATE format

    Hi,
    I need the data format in this format  DD-MM-YYYY HH:MI:SS
    So, I m using    select TO_CHAR(Date_Column, 'DD-MM-YYYY HH:MI:SS')  from dual;
    Now, In my procedure I need to assign this to a OUT  variable, what should be the Data type of out variable.
    My OUT variable is used by other program.
    Thanks

    You can use VARCHAR2. Try the below
    CREATE OR REPLACE PROCEDURE proc_test(p_indate DATE, p_outdate OUT VARCHAR2) 
    AS 
    BEGIN 
       p_outdate:= TO_CHAR(p_indate,'DD-MON-YYYY HH:MI:SS'); 
    END; 
    SET SERVEROUTPUT ON
    DECLARE 
       v_date  VARCHAR2(50); 
    BEGIN 
       proc_test(SYSDATE,v_date);
       DBMS_OUTPUT.PUT_LINE(v_date);  
    END; 
    OUTPUT:-
    anonymous block completed
    15-JAN-2014 12:13:46

  • Test String for date format

    Is there a function that reads a string and can return yes/no if the string matches a specified date format (example: mm/dd/yy)? I wish to avoid parsing the string character by character.
    Thanks,
    George

    BTW,
    I used the following example code available from this site. I was able to easily modify it to sovle my problem.
    try {
    SimpleDateFormat formatter =
    new SimpleDateFormat("EEEE, MMMM dd, yyyy");
    Date d = formatter.parse(
    "Tuesday, January 03, 1956");
    formatter = new SimpleDateFormat(
    "EE, MMM d, yy");
    d = formatter.parse("Tue, Jan 3, 56");
    formatter = new SimpleDateFormat(
    "EE, MM d, yy");
    d = formatter.parse("Tue, 01 3, 56");
    process(d);
    } catch (ParseException e) {
    On to the next challenge...
    George

  • Transformations for Date Format

    I have a flat file which contains a field for date as 02-10 for MMYY, how can I change it to 0210, can I use formula builder?

    Hi,
    Copy and Past teh below program, and implement the same logic for your requirements.
    REPORT  ZBITEST.
    Data: zdd type sy-datum,
          zmm(2) type n,
          zyy(4) type n,
          zd(2) type n,
          zdm(6) type n.
          zdd = sy-datum.
          zd = zdd+6(2).
          zmm = zdd+4(2).
          concatenate zd zmm into zdm.
          write:/ zdd.
          write:/ zd.
          write:/ zmm.
          write:/ zdm.
    Thanks
    Reddy

  • Error Message for Date Format

    Hi Friends,
    Could you guys help me with sample code in java script to throw error message if the user enter the wrong date format( my requirements of date format like yyyymmdd)in BSP.
    Regards
    CSM Reddy

    you dont have to write the js code.
    just set the input field<b> type = date</b> and <b>dovalidate=true</b>
    if the user tries to submit the form with wrong format, the system will throw javascript error message and will not submit the form.
    Regards
    Raja

  • #ERROR message in report for date format conversion

    Dear Collegues,
    Why is it that I get #ERROR message (instead of date value) in my report when I use the formula
    =ToDate(UserResponse("Enter End Date:");"dd.MM.yyyy")   ??
    When I only write UserResponse("Enter End Date:") I get the appropriate date, f.ex 5/12/2009. This is american standard for 5th of may, I need to see it like 12/05/2009.
    If I try to just enter the date object behind the prompt ([Settlement Date]) i get message #MULTIVALUE even though I have promptet for 1 special date...
    Is there another formula I can use to get the right format? I can't adjust the format using properties, it doesn't make any difference, the settings I put in there.
    Regards Silje

    Thank you for the very quick answer! Using FormatDate() I get an error message while validating the formula:
    The expression or sub-expression at position 12 in the FormatDate function uses an invalid data type. (WIS 10037)
    I tried making a variable inside BO called [End Date] = userResponse("Enter End Date:") but I get the same error message then. Creating a variable you can only choose between Dimension, Measure and Detail, not Date. Is that some of the reason?
    Finally I tried FormatDate([Settlement Date]; "dd.MM.yyyy"). Validating the formula I get the message that the formula is correct, but in the report the field containes message #MULTIVALUE...
    SILJE

Maybe you are looking for