Convert string date

Dear experts.
How can I transfer a string date into string date of previous year, Ex: 24.10.2008  into => 24.10.2007
Thanks for your reply
Huynh Kim Binh

Hi
I got a solution, fomular is: DSTR(DADD(STORE@Date,-1,'Y'),"DD.MM.YYYY")
Thanks
HKBinh
Edited by: Huynh Binh on Oct 25, 2008 5:17 AM

Similar Messages

  • Need to convert string data to numbers.

    I have string data that I need to convert to numbers so that I can graph it or perform calculations on it. The data (file attached) is in three columns (tab separated) and is in the format time/double/time (saved as a string with Write haracters to File.) When I try Read From Spreadsheet I get 0.0000 for column 1 and 2.0000 for column 3.
    Attachments:
    testOK.txt ‏1 KB

    Hi,
    I've done this through scan from file, using %s%f%s%s so I get the relative time, numeric, time, PM
    See the attached .vi.
    Hope it helps
    S.
    // it takes almost no time to rate an answer
    Attachments:
    disect_data.vi ‏46 KB

  • How to convert String date to java sql date

    I have an html form for entering the Date on retreving that value in a java servlet i get it as a string i want to convert that date to SQL date format so that i could use setDate() method of the java.sql.Date class to update the date value in the database.
    i used the following way but i need the code without using the deprecated ones.
    String delDate = (String)p_Request.getParameter("deleteDate");
    [b]java.util.Date utilDate = new java.util.Date(delDate);
    java.sql.Date deleteDate = new java.sql.Date(utilDate.getTime());
    custCode = (String)p_Request.getValue("custCode");
    thanx in advance.

    Check out the later posts in http://forum.java.sun.com/thread.jspa?threadID=647681&messageID=3814745#3814745

  • How to convert string date to long (or Unix date)?

    I'm having difficulty in converting a user supplied date in the format mm/dd/yyyy to a long format such as 1035462807000. Since it's being entered by the user I can't just use the current system date. Any suggestions? Thanks!
    Dave

    Hi man, tsith Gave a good beggining, why dont you try the next code
    import java.text.DateFormat;
    import java.text.SimpleDateFormat;
    import java.text.ParseException;
    import java.util.Date;
    public class DateToUnix{
        public static void main(String args[]){
            getDateAsLong();
        public static void getDateAsLong(){
            String sStartDate = "12/01/2002";
            Date theDate;
            DateFormat sdf= new SimpleDateFormat("MM/DD/yyyy" );
            try {
                theDate = sdf.parse( sStartDate );
            }catch(ParseException e ){
                theDate = new Date();
            System.out.println( "Converted Start Date:" + theDate.getTime());
    }No mather how you get a Date object, the value you are looking for is a long, and you can get it from such object with the getTime() method.
    Take a look at the Java API @ [http://java.sun.com/j2se/1.4.1/docs/api/java/util/Date.html#getTime()]

  • LV 8.5.X: Converting String Data/Time to Timestamp

    Hello again,
    is there really no convenient way to convert a String Data/Time to an
    Timestamp?
    Thanks and greetings
    Udo

    You can use the Scan from String function:
    Look at the bottom for an example. If you can't get the format string right, you can configure a timestamp control/indicator to what you need and then use the properties (right click) then select Advanced at the bottom to get the string you need.
    Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
    If you don't hate time zones, you're not a real programmer.
    "You are what you don't automate"
    Inplaceness is synonymous with insidiousness

  • Converting String Date to Date Format

    Hope you can help, I am tearing my hair out. I have a 2D table that stores information. I have a field that records a date in the format 03-May-11 (this is a string). However, it is also stored as a number 40666 in a sortkey field. The string field is CLIENT2D.INFO1 and i have tried to use Date({CLIENT2D.INFO1}) to show as a date, which it does, until i want to use it as a parameter i.e. bring records between two dates. It errors and comes up with bad date format.
    Is the 40666 number Unix Time? If so is there anyway to convert this to a Date 03/05/11?

    Try
    CDate({CLIENT2D.INFO1})
    Ian

  • Converting string data from a web service respons into XML structure of XI

    Hi,
    We receive a string structure from a web service.
    The string structure has an xml type format, that is all the tags and its content are in one line .
    The WSDL file of the webservice defines its response structure as a string type.
    How do i convert this string into proper XML structure (predefined by me in Integration repository).
    OR how do i make XI understand this string as an XML structure for further processing.
    Later i have to map this XML message type into IDoc.
    Himani

    Hi Himani,
    Please find the code for ur requirement -
    String need to parse -<response_webservice><from_date>20080101</from_date><to_date>20080202</to_date></response_webservice>
    Below mentioned code will convert it to -<MT_DATA><FROMDATE>20080202</FROMDATE><TODATE>20080101</TODATE></MT_DATA>
    Create a Message type and map it like this using java mapping ( no need to use Graphical mapping).
    Use MT_DATA as source and map it to your target structure .
    import java.io.FileInputStream;
    import java.io.IOException;
    import java.io.StringReader;
    import java.util.HashMap;
    import java.util.Map;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.FactoryConfigurationError;
    import javax.xml.parsers.ParserConfigurationException;
    import javax.xml.transform.TransformerFactoryConfigurationError;
    import org.w3c.dom.DOMException;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.NodeList;
    import org.w3c.dom.Text;
    import org.xml.sax.InputSource;
    import org.xml.sax.SAXException;
    public class XMLParser {
         private Map param = null;
         public static void main(String[] args) {
              try {
                   XMLParser wdb = new XMLParser();
                   wdb.parse();
              } catch (Exception e) {
                   e.printStackTrace();
         public void setParameter(Map param) {
              this.param = param;
              if (param == null) {
                   this.param = new HashMap();
         public void parse() {
              String document = "<response_webservice><from_date>20080101</from_date><to_date>20080202</to_date></response_webservice>";
              try {
                   Document sdoc;
                   DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
                   // Using factory get an instance of document builder
                   DocumentBuilder db = dbf.newDocumentBuilder();
                   // parse using builder to get DOM representation of the XML file
                   sdoc = db.parse(new InputSource(new StringReader(document)));
                   Element docEle = sdoc.getDocumentElement();
                   NodeList nl = docEle.getElementsByTagName("from_date");
                   Element lstElmnt = (Element) nl.item(0);
                   NodeList nl1 = docEle.getElementsByTagName("to_date");
                   Element fstElmnt = (Element) nl1.item(0);
                   System.out.println(fstElmnt.getFirstChild().getNodeValue());
                   System.out.println(lstElmnt.getFirstChild().getNodeValue());
                   Document tdoc = db.newDocument();
                   Element structure = createElement("MT_DATA", null, tdoc);
                   tdoc.appendChild(structure);
                   Element statement = createElement("FROMDATE", fstElmnt.getFirstChild().getNodeValue(), tdoc);
                   structure.appendChild(statement);
                   Element statement2 = createElement("TODATE", lstElmnt.getFirstChild().getNodeValue(), tdoc);
                   structure.appendChild(statement2);
                   System.out.println("Struct is :::"+tdoc.getDocumentElement().toString());               
              } catch (DOMException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              }  catch (IOException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              } catch (FactoryConfigurationError e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              } catch (ParserConfigurationException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              } catch (SAXException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              } catch (TransformerFactoryConfigurationError e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
         static Element createElement(String elementName, String content,
                   Document document) {
              Element returnElement;
              returnElement = document.createElement(elementName);
              if (content != null) {
                   Text T = document.createTextNode(content);
                   returnElement.appendChild(T);
              return returnElement;
         static Element createElement(String elementName, String content,
                   String attributeName, String attributeValue, Document document) {
              Element returnElement = createElement(elementName, content, document);
              returnElement.setAttribute(attributeName, attributeValue);
              return returnElement;
    Regards,
    Kishore

  • How to convert a String data to Double or Float???? Thank you

    I need to convert String data to Double or Float , please help me about it. Thank you very muh!
    String a=Integer.parseInt("1234"); convert to integer.

    I found it but do not know if it is ok
    float a= Float.valueof(String to
    convert).floatValue();
    may be it can be!!!
    Thank you !!!!How did parseInt lead you do valueOf?
    Look for something more consistent. A pattern.As I said earlier, it depends if he wants an object or a primitive.
    � {�                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Not able to convert string attribute to number and date please help me out

    not able to convert string attribute to number and date attribute. While using string to date conversion it shows result as failure.As I am reading from a text file. please help me out

    Hi,
    You need to provide an example value that's failing and the date formats in the reference data you're using. It's more than likely you don't have the correct format in your ref data.
    regards,
    Nick

  • Convert String to Date and Format the Date Expression in SSRS

    Hi,
    I have a parameter used to select a month and year  string that looks like:    jun-2013
    I can convert it to a date, but what I want to do is,  when a user selects a particular month-year  (let's say "jun-2013")
    I  populate one text box with the date the user selected , and (the challenge Im having is)  I want to populate a text box next to the first text box with the month-year  2 months ahead.    So if the user selects 
    jun-2013   textbox A will show  jun-2013 
    and textbox B will show  aug-2013..
    I have tried:
    =Format(Format(CDate(Parameters!month.Value  ),  
    "MM-YYYY"  )+ 2  )   -- But this gives an error
    This returns the month in number format   like "8"    for august...
    =Format(Format(CDate(Parameters!month.Value  ), 
    "MM"  )+ 2  )
    What is the proper syntax to give me the result    in this format =  "aug-2013"  ???
    Thanks in advance.
    MC
    M Collier

    You can convert a string that represents a date to a date object using the util.scand JavaScript method, and then format a date object to a string representation using the util.printd method. For more information, see:
    http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.1254.html
    http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.1251.html
    In your case, the code would be something like:
    var sDate = "2013-01-10";
    // Convert string to date
    var oDate = util.scand("yyyy-mm-dd", sDate);
    // Convert date to new string
    var sDate2 = util.printd("mm/dd/yyyy", oDate);
    // Set a field value
    getField("date2").value = sDate2;
    The exact code you'd use depends on where you place the script and where you're getting the original date string, but this should get you started.

  • 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);

  • How to convert String (dd-MMM-yyyy) to oracle.jbo.domain.Date

    Hi
    Could you please tell how do I convert String of date in format dd-MM-yyyy to ADF date? Please show me some sample.
    Thanks

    http://javaalmanac.com/egs/java.text/FormatDateDef.html
    Once you have a java.util.Date you can convert it to oracle.jbo.domain.Date. (see http://www.fifkredit.com/bc4jdoc/rt/oracle/jbo/domain/Date.html)

  • Facing problem in converting string to date using getOANLSServices()

    I am trying to set a value for date field in my vo and trying to insert into the table.
    In controller I am getting the String which has a date:
    ex: String date="01-NOV-2007";
    while setting into the row I need to convert into Date but it is returning null.
    The below code I used
    to convert into date :
    Date dt = new Date(getOADBTransaction().getOANLSServices().stringToDate(date));
    But this dt is returning a null value is there any solution please advise me.
    Regards!
    Smarajeet

    Smarajeet ,
    See this thread, in one of my replies i have mentioned how to convert string to java.sql.date.You can use the same for oracle.jbo.domain.Date.
    urgent!How to set the default selected date for an OAMessageDateFieldBean
    --Mukul                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Converting string to util date

    I have a method to define if a string value can be converted into date.
    When I pass "20080815" value as a parameter it works fine. But when I pass "20082415" value it also converts the value to a date where the value should not be converted to date. At least I expect so. It should throw an exception because month can not be 24.
    Why an how could it be? And is there another way to solve the situation?
        public static int ToDate(String p_value) {
            try {
                DateFormat df = new SimpleDateFormat("yyyyMMdd");
                date_val = df.parse(p_value);
                return 1;
            catch(Exception e) {
                return -1;
        }Edited by: kalyon on Sep 4, 2008 3:50 AM
    Edited by: kalyon on Sep 4, 2008 3:50 AM

    df.setLenient(false);read the API docs.

  • How to convert string to date

    HI Everyone,
    i am trying to convert a date which is in string format to a date format...but i am having this error
    javax.servlet.ServletException: Unparseable date: "2004-05-03"
    Can anyone help?
    Here is a piece of code :-
    SimpleDateFormat formatter= new SimpleDateFormat ("yyyy-mm-dd");
    Date today = formatter.parse(fulldate);

    You need to change your formatting string to: "yyyy-MM-dd" Lower case 'm' is for minutes...

Maybe you are looking for

  • High Response Times with 50 content items in a Publisher 6.5 portlet

    Folks, Have set up a load test, running with a single user, in which new News Article content items are inserted into a Publisher 6.5 portlet created of the News Portlet template. Inserts have good response times through 25 or so content items in the

  • Plz solve this simple problem.

    here is my program code: import java.awt.*; import java.awt.event.*; import java.applet.*; import javax.swing.*; public class Coordinate extends JApplet implements ActionListener { private JLabel lb1, lb2; private JTextField ta1, ta2; private String

  • Badi-error message?

    Hi, Once the user wants to release an account some validation has to be done and restrict the user to release... 1.I have used one Badi and i put one Error mesage....but Error mesage is producing short dump. 2..I changed the mesage to type 'I' and be

  • Import crashes program

    In CS6 it is WAY too easy to import an entire folder by accidentally double clicking (depending on view)... It crashes the program every time. Is there a setting I can change?

  • Internet not being detected

    I just bought a macbook pro, and I am having problems with my wifi detecting the internet. Occasionally if works, but most of the time I have no internets listed when i try to connect. I have multiple other apple devices connected to the same interne