Converting a date to a string

Post Author: ralc002
CA Forum: Formula
I have done a quick search of the forums but did not find what I needed so here it goes:
I have a date field (which is really a date time field - sql).  I only use the date so the time is always 00:00:00
Now I have a formula which shows "The last stored date is " & ToText()"
Obviously doing that would show the time (00:00:00).  Now I realize that I could format it to exclude the time (e.g. ToText(,"dd/MM/yyyy"), but the problem is doing that hard codes the format.  If I create a report for international use, the date format I used in the example would not be valid in the US for example, since it is in british format. 
Is there a way to convert a datetime field to a string so that only the date (and not the time) is displayed in the proper format for the current locale?
Thanks

Post Author: SKodidine
CA Forum: Formula
How about just
"The last stored date is " & date()
and that way no matter who sees the report, their local settings will determine how the date is displayed.

Similar Messages

  • Converting premitive data types into strings

    Hello everybody,
    I have a small doubt. Is it possible to convert all data types like int, boolean etc to strings. I know it is possible to convert them individually. But I would like to have it a common method to convert them all. Because I am reading the whole line, so it is taking as strings. I am unable to read their original data types, all are reading as strings.
    Can anybody tell me how to solve this problem?
    Thank you in advance,
    Kashi.

    Hi all,
    Thanx for your answers. But as I told you before I don't know the exact data type of those. Because I am reading whole file by using DataInputStream's readLine() method. It returns the whole line as String. If there are any integer or boolean etc, it converts them as strings. So I could not read the exact data type of them.
    for example:
    int a = 10;
    boolean b = true;
    String str = "The Values are" + a + b;
    this code is in one file. If I read this file from another file, the line
    String str = "The Values are" + a + b;
    reads as a string, but I couldn�t get the 'a' as ineger and 'b' as boolean. it gives they are of strings.
    Thanx,
    Kashi.

  • Error While trying to Convert a Date Value to string in POI API (Excel)

    Hi
    How can I convet a date value in excel to string value ? I am using POI API for excel sheet reading in JSP .

    Hello Esther,
    the problem seems to be that the temp folder of the target Integration Builder system can't be found:
    'The system cannot find the path specified
    at [..] FileAccess.getTempDirectory([..])'.
    You'll experience the same problem if you try a file based import or export within the Integration Builder directly.
    I would recommend to continue the search there. You could check if the environment variables (for Windows: TEMP and TMP) of the OS of the system with the target Integration Builder to an existing path. Check also if the WebAs can access this path.
    Good luck
    Frank

  • Converting a date to a string in J2ME?

    How come this code:
    Calendar cal = Calendar.getInstance();
    cal.setTime(new Date()) ;
    String s = cal.getTime().toString();
    Form f = new Form("Date");
    f.append(new StringItem("Date", s));
    display.setCurrent(f);
    produce something like this: java.util.Date@226de234
    in J2ME (in a mobile phone emulator) when all I want is a string like
    this: Wed Jul 02 19:36:44 GMT+10:00 2003
    which this code in J2SE with ease produces:
    Calendar cal = Calendar.getInstance();
    cal.setTime(new Date()) ;
    String s = cal.getTime().toString();
    System.out.println(s);
    Is there anyone who can tell me how to get the string in J2ME?
    -B-

    Post Author: SKodidine
    CA Forum: Formula
    How about just
    "The last stored date is " & date()
    and that way no matter who sees the report, their local settings will determine how the date is displayed.

  • Convert SSIS DateTime to a String

    Being a newbie to SSIS I'm not sure of the most efficient method of converting a DateTime object to a String.
    I'm from a C# background where this would be easy using DateTime.ToString("YYYYMMdd"). I want to use the date in a file name so don't require most of the parts.
    I'm sure I could do this using a script task to produce a file name for each row of data in my table and add that filename to the dataset but it seem like overkill to do something that should be simple. Also as I'm supposed to be getting to grips with SSIS I shouldn't keep running back to what I know.
    My current approach is to derive a column and build up an expression to convert the date into a string. The only problem being that it doesn't work.
    The expression I'm working with is:
    (DT_WSTR, 50)([OrgName] ) + "_" + (DT_WSTR, 50)( [PayrollName] ) + (DT_WSTR, 4)(YEAR( [ProcessedDate] )) + (DT_WSTR, 2)(MONTH( [ProcessedDate] )) + (DT_WSTR, 2)(DAY( [ProcessedDate] )) ".txt"
    Can anyone see where I'm going wrong?
    All comments greatly received.
    Cheers
    Ben

    Doesn't work ? What is the error you are getting ?
    Use dt_str instead. Here is an example I am using successfully...
    Code Snippet
    "FileName_" + (DT_STR,4,1252) DatePart("yyyy",getdate()) +
    Right("0" + (DT_STR,4,1252) DatePart("m",getdate()),2) +
    Right("0" + (DT_STR,4,1252) DatePart("d",getdate()),2) + Right("0" + (DT_STR,4,1252) DatePart("hh",getdate()),2) +Right("0" + (DT_STR,4,1252) DatePart("n",getdate()),2) +".txt"

  • Convert a date in String format to a Date

    Hi,
    How can I convert a date in String format to a Date object?
    I have tried:
    import java.text.*;
    import java.io.*;
    import java.util.Date;
    import java.util.Locale;
    import java.sql.*;
    public class casa {
    public static Connection con = null;
    public static Statement s = null;
    public static String sql = null;
    public static String mydate = "01.01.2001";
    /** Creates a new instance of casa */
    public casa() {
    public static void main(String[] args) throws SQLException{
    try {
    DateFormat shortFormat = DateFormat.getDateInstance(DateFormat.SHORT);
    Date date = shortFormat.parse(mydate);
    //Open Database
    con = getConnection();
    s = con.createStatement();
    sql = "select date1 from table1 where date1 <= '"+date+"'";
    ResultSet rs = s.executeQuery(sql);
    while(rs.next()){
    String aba = rs.getString("datum");
    System.out.println("New Datum = "+aba);
    } catch (Exception ex ) {
    ex.printStackTrace();
    closeConnection(s, con);
    //Connection
    private static Connection getConnection() {
    Connection con = null;
    String user ="aouzi";
    String passe ="aouzi";
    String url = "jdbc:db2:EjbTest";
    try {
    //Datenbanktreiber laden
    Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");
    //Verbindung herstellen
    con = DriverManager.getConnection(url,user,passe);
    }catch(ClassNotFoundException e){
    } catch(SQLException e){}
    return con;
    //close Connection
    private static void closeConnection(Statement s, Connection con) {
    try {
    s.close();
    } catch (SQLException e) {}
    try {
    con.close();
    } catch (SQLException e) {}
    I'm getting the following errors:
    COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2/NT] SQL0180N
    The syntax of the representation of a date/time of day value as character sequence is false. .SQLSTATE=22007

    I'm pretty sure it won't understand what date.toString() returns. If you know what format the database understands, you do it like this:
    SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yy"); // e.g. 18-Apr-02
    String datestring = sdf.parse(date);
    and use that instead of date in your sql string. Some databases understands it if you do
    "to_date('18-Apr-02')"
    so you could include that in your sql string as well..
    You could also try to make it a java.sql.Date and hope your jdbc driver knows how to convert it to a string that the database understands if you don't know the format:
    con = getConnection();
    PreparedStatement ps = con.prepareStatement("select date1 from table1 where date1 <= ?");
    ps.setDate(new java.sql.Date(date.getTime()));
    ResultSet rs = s.executeQuery(sql);

  • Converting hexadecimal XML data to a string

    Hello!
    Until now I generated XML data with the FM 'SDIXML_DOM_TO_XML'.
    After that I did a loop over the xml_as_table in which I was casting each line of that table to a string.
    ASSIGN <line> TO <line_c> CASTING.
    After the inftroduction of unicode in our system I get a error:
    In the current program an error occured when setting the field symbol <LINE_C> with ASSIGN or ASSIGNING (maybe in combination with the CASTING addition).
    When converting the base entry of the field symbol <LINE_C> (number in base table: 32776), it was found that the target type requests a memory alignment of 2
    What does it mean? Does somebody have a solution.
    I need this function for sending this XML data as string over a simple old CPIC connection.
    Best regards
    Martin

    Hello Martin
    Perhaps my sample report ZUS_SDN_XML_XSTRING_TO_STRING provides a solution for your problem.
    *& Report  ZUS_SDN_XML_XSTRING_TO_STRING
    *& Thread: Converting hexadecimal XML data to a string
    *& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1029652"></a>
    REPORT  zus_sdn_xml_xstring_to_string.
    *-- data
    *-- read the XML document from the frontend machine
    TYPES: BEGIN OF xml_line,
            data(256) TYPE x,
          END OF xml_line.
    DATA: xml_table TYPE TABLE OF xml_line.
    DATA: go_xml_doc       TYPE REF TO cl_xml_document,
          gd_xml_string    TYPE string,
          gd_rc            TYPE i.
    PARAMETERS:
      p_file  TYPE localfile  DEFAULT 'C:payload_idoc.xml'.
    START-OF-SELECTION.
      CREATE OBJECT go_xml_doc.
      " Load XML file from PC and get XML itab
      CALL METHOD go_xml_doc->import_from_file
        EXPORTING
          filename = p_file
        RECEIVING
          retcode  = gd_rc.
      CALL METHOD go_xml_doc->get_as_table
        IMPORTING
          table   = xml_table
    *      size    =
    *      retcode =
    " NOTE: simulate creation of XML itab
      go_xml_doc->display( ).
      create object go_xml_doc.
      CALL METHOD go_xml_doc->parse_table
        EXPORTING
          table   = xml_table
    *      size    = 0
        receiving
          retcode = gd_rc.
      CALL METHOD go_xml_doc->render_2_string
    *    EXPORTING
    *      pretty_print = 'X'
        IMPORTING
          retcode      = gd_rc
          stream       = gd_xml_string
    *      size         =
      write: / gd_xml_string.
    END-OF-SELECTION.
    Regards
      Uwe

  • How do I convert a Variant of type=String to G data? (LV 5.1.1)

    I've tried to return a string in the Variant return of a VB function in a DLL. (I want to do this so that I can retain the interface and thus binary compatibility in the DLL.)
    When I use the DLL function in LabVIEW 5.1.1 I
    get an error in the call library function call (returning). It looks like there is a way to handle this in v 6.0 but I have to use 5.1.1 for this application. Is there a way for LV 5.1.1 to handle a Variant containing a string?
    Thanks
    Dave Karon
    Concepts NREC

    Hi Dave,
    you can use the type conversion function located under advanced -> data
    manipulation to convert the variant into a string.
    Henrik
    Dave Karon schrieb in im Newsbeitrag:
    [email protected]..
    > I've tried to return a string in the Variant return of a VB function
    > in a DLL. (I want to do this so that I can retain the interface and
    > thus binary compatibility in the DLL.)
    > When I use the DLL function in LabVIEW 5.1.1 I
    > get an error in the call library function call (returning). It looks
    > like there is a way to handle this in v 6.0 but I have to use 5.1.1
    > for this application. Is there a way for LV 5.1.1 to handle a Variant
    > containing a string?
    >
    > Thanks
    > Dave Karon
    > Concepts NREC

  • How to convert BLOB data into string format.

    Hi,
    I have problem while converting blob data into string format.
    for example,
    Select dbms_lob.substr(c.shape.Get_wkb(),4000,1) from geotable c
    will get me the first 4000 byte of BLOB .
    When i using SQL as i did above,the max length is 4000, but i can get 32K using plsql as below:
    declare
    my_var CLOB;
    BEGIN
    for x in (Select X from T)
    loop
    my_var:=dbms_lob.substr(x.X,32767,1)
    end loop
    return my_var;
    I comfortably convert 32k BLOB field to string.
    My problem is how to convert blob to varchar having size more than 32K.
    Please help me to resolve this,
    Thanx in advance for the support,
    Nilesh

    Nilesh,
    . . . .The result of get_wkb() will not be human readable (all values are encoded into some binary format).
    SELECT utl_raw.cast_to_varchar2(tbl.geometry.get_wkt()) from FeatureTable tbl;
    -- resulting string:
        ☺AW(⌂özßHAA
    Å\(÷. . . .You may also want to have a look at { dbms_lob | http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_lob.htm#i1015792 } "The DBMS_LOB package provides subprograms to operate on BLOBs, CLOBs, NCLOBs, BFILEs, and temporary LOBs."
    Regards,
    Noel

  • Convert the date of string to datetime format 'MM/dd/yyyy' when the system date format is 'dd/MM/yyyy'.

    I need convert the date of string format 'MM/dd/yyyy' to datetime format 'MM/dd/yyyy' when the system date format is 'dd/MM/yyyy'.Since
    I need to search values based on date where my database datetime  is 'MM/dd/yyyy' format.

    In my opinion you should re-consider the assumption that the date picker returns a string. Maybe it is able to return a
    DateTime object directly instead of string. Then you will pass this value as a parameter of SQL query. This should work regardless of computer configuration.
    Otherwise, follow the previous string-based approaches.

  • Converting any date string to GMT standard

    Hi All,
    I want to convert any date string to GMT standard.
    The date string may be like this.
    "Sat Sep 15 14:23:40 IST 2001"
    I have tried to change my defaultTimeZone .
    But I don't know why it's not working.
    Is there something to do with Locals?
    Can anyone please tell me the way to
    accomplish that ?
    Thanks in advance.
    Sujoy

    Java stores all the dates in GMT Format , considering the machines TimeZone Setting ....and also i guess date has methods like toGMTString() and toLocaleString() . To convert the date to GMT i guess u can just say toGMTString() of the date . If u have the stringified version of date
    just make a new Date(String) and then calling toGMTString of it .

  • How to convert DateField date to String ?

    Hi,
    I'm trying to convert DateField date to String.
    How can I do it because Data class does not have String converting
    methods...
    Thanks
    Krzysztof

    Hello,
    you can get an instance of Calendar and use it with the date as a long integer.
    public Calendar cal=Calendar.getInstance();
    myDate=dateField.getDate();
    cal.setTime(myDate);
    myDateString=cal.get(Calendar.DATE)+"."+cal.get(Calendar.MONTH)+"."+cal.get(Calendar.YEAR));
    Try it.
    Unfortunately I have found that the MIDlet get a day less when I use the same long integer that I got from an application on PC. I don't realy understand why but I' still searching.
    I hope it is usefull for you.
    ValeriuS

  • I have a string 2012-05-22T23:23:42.263-07:00. so i want to convert in date with indian time zone   can any one help me out

    i have a string 2012-05-22T23:23:42.263-07:00. so i want to convert in date with indian time zone   can any one help me out

    What does this have to do with iPhone tech support?

  • Converting Date-Time to Long Date in a string that is stored in a formula

    The following are 2 verions of formulas that I've tried in placing the long date on a report.  I want the JUD_T_MEETING_NOTICE.MEETING_DATE to be displayed on the letter if Outcome_ID = 3.00 as April 29, 2009.  The field's fomat in the table is 04/29/2009 and neither of the formula's below worked.  I tried formatting the date as a separte formula, as shown in Formula #2 below, but the formatting defaults to the original DataType.  Anyone have any ideas on how to format the date within the string in the formula?
    FORMULA #1:
    IF {JUD_T_MEETING_NOTICE.FK_OUTCOME_ID} = 3.00
    THEN 'I received the enclosed report(s) for review.  To resolve this matter, you must contact the office at ' & {@HallPhone} & ' to schedule a meeting to discuss the incident with me.  This meeting must occur by ' & DATETIMETODATE({JUD_T_MEETING_NOTICE.MEETING_DATE}) & '.  If you have a conflict with this deadline, please let me know as soon as possible to make alternative meeting arrangements.'
    ELSE IF {JUD_T_MEETING_NOTICE.FK_OUTCOME_ID} = 9.00
    THEN 'You missed your scheduled meeting.'
    FORMULA #2:
    IF {JUD_T_MEETING_NOTICE.FK_OUTCOME_ID} = 3.00
    THEN 'I received the enclosed report(s) for review.  To resolve this matter, you must contact the office at ' & {@HallPhone} & ' to schedule a meeting to discuss the incident with me.  This meeting must occur by ' & ({@FormatMeetingDate}) & '.  If you have a conflict with this deadline, please let me know as soon as possible to make alternative meeting arrangements.'
    ELSE IF {JUD_T_MEETING_NOTICE.FK_OUTCOME_ID} = 9.00
    THEN 'You missed your scheduled meeting.'

    Assuming JUD_T_MEETING_NOTICE.MEETING_DATE is a date field, modify your formula to:
    totext(({JUD_T_MEETING_NOTICE.MEETING_DATE}),"MMMM dd, yyyy")
    If it is not a date field but a string, then
    totext(cdate(JUD_T_MEETING_NOTICE.MEETING_DATE ),"MMMM dd, yyyy")

  • Cannot convert type class java.lang.String to class oracle.jbo.domain.Clob

    Cannot convert type class java.lang.String to class oracle.jbo.domain.ClobDomain.
    Using ADF Business Components I have a JSFF page fragment with an ADF form based on a table with has a column of type CLOB. The data is retrieved from the database and displayed correctly but when any field is changed and submitted the above error occurs. I have just used the drag and drop technique to create the ADF form with a submit button, am I missing a step?
    I am using the production release of Jdeveloper11G

    Reproduced and filed bug# 7487124
    The workaround is to add a custom converter class to your ViewController project like this
    package oow2008.view;
    import javax.faces.application.FacesMessage;
    import javax.faces.component.UIComponent;
    import javax.faces.context.FacesContext;
    import javax.faces.convert.Converter;
    import javax.faces.convert.ConverterException;
    import oracle.jbo.domain.ClobDomain;
    import oracle.jbo.domain.DataCreationException;
    public class ClobConverter implements Converter {
         public Object getAsObject(FacesContext facesContext,
                                   UIComponent uIComponent,
                                   String string) {
           try {
             return string != null ? new ClobDomain(string) : null;
           } catch (DataCreationException dce) {
             dce.setAppendCodes(false);
             FacesMessage fm =
               new FacesMessage(FacesMessage.SEVERITY_ERROR,
                                "Invalid Clob Value",
                                dce.getMessage());
             throw new ConverterException(fm);
         public String getAsString(FacesContext facesContext,
                                   UIComponent uIComponent,
                                   Object object) {
           return object != null ?
                  object.toString() :
                  null;
    }then to register the converter in faces-config.xml like this
    <faces-config version="1.2" xmlns="http://java.sun.com/xml/ns/javaee">
      <application>
        <default-render-kit-id>oracle.adf.rich</default-render-kit-id>
      </application>
      <converter>
        <converter-id>clobConverter</converter-id>
        <converter-class>oow2008.view.ClobConverter</converter-class>
      </converter>
    </faces-config>then reference this converter in the field for the ClobDomain value like this
              <af:inputText value="#{bindings.Description.inputValue}"
                            label="#{bindings.Description.hints.label}"
                            required="#{bindings.Description.hints.mandatory}"
                            columns="40"
                            maximumLength="#{bindings.Description.hints.precision}"
                            shortDesc="#{bindings.Description.hints.tooltip}"
                            wrap="soft" rows="10">
                <f:validator binding="#{bindings.Description.validator}"/>
                <f:converter converterId="clobConverter"/>
              </af:inputText>

Maybe you are looking for

  • My Display Only Works Part of the Time and Apple Care Won't Help Me (Long)

    I bought my computer at a discounted price because it was a restocked item, but was it really worth it? I'm beginning to think not. I saw that it had one stuck pixel, but saving that much money on such an expensive computer, the pixel hardly seemed l

  • FTP adapter problems

    Hi all, I'm having some problems with the FTP adapter. About two months ago I did an ESB project which reads from an FTP and writes the files in a local directory. I noticed that I had to change this parameter oracle.tip.adapter.file.numProcessorThre

  • TS4000 My reminders to not show up in the calendar

    My reminders to not show up in the calendar.  All of the documents say clicking settings on the calendar page will have a 'Show Reminders'.  I see no such thing.  What am I missing?

  • Where are the iWeb file(s?) saved?

    Hi, When I'm working on a site and then press cmd+S (File>Save), where are the iWeb file(s?) saved? I'm looking for those files which I need to backup in case my harddisk would crash some day... Thanks!

  • Error in taana Tcode

    Dear all,         Am facing the error while opening the TAANA tcode (Variant does not exist )  ,While in the development it's working fine ,as  in qlt through the errror. Please let me know to solve this promblem. Regards, Sunny