Converting String to datetime format

I have a String which is in 04-DEC-78 format, I want it to be inserted in to a field in sql database.If I map directly I am getting
"Microsoft.ServiceModel.Channels.Common.XmlReaderParsingException: The input data for the field/parameter "e_date" is invalid according to the expected SqlDbType DateTime. ---> System.FormatException: The string '04-DEC-65' is not a valid
AllXsd value.
Tried to convert the string to datetime format in Mapping but getting error
public DateTime FormatCheck(string param1)
IFormatProvider culture = new CultureInfo("en-US", true);
return  DateTime.ParseExact(param1, "dd/MM/yyyy HH:mm:ss.fff", culture);
Inline Script Error: The type or namespace name 'CultureInfo' could not be found (are you missing a using directive or an assembly reference?) 
Help me out!!

HOLD ON!
Let's try to clear this up. If the input data is "04-DEC-78" then, sorry, none of the code posted so far will work.
"04-DEC-78" is not directly parsable so the .ParseExact format must match the source.
The format for xs:datetime is ISO 8601 which is like yyyy-MM-ddTHH:mm:ss-[offset].  Internally the sqlBinding will cast the XsdDateTime (the .Net xs:datetime implementation) to a SqlDateTime.
One very, very important missing detail is the type of the SQL parameter.  Is it (SQL) datetime or string?
If the SQL parameter is datetime, then you can use this:
public string FormatCheck(string param1)
return DateTime.ParseExact(param1, "dd-MMM-yy", System.Globalization.CultureInfo.InvariantCulture).ToString("s");

Similar Messages

  • Converting string into datetime format

    Hi,
    I have a report within Apex that runs based on a select query. This select query uses a decode statement which retrieves the relevant date for each row. I am using to_char(hd.PLANNED_IMPL_DATE,'DD-MON-YY HH24:MI') in my select query to retrieve the times for each date. However when I try sorting the column, it sorts the dates according to strings. For example 08 OCT 08 14:00 will appear before 08 SEP 08 12:00.
    Is there any way where i can change the data type to a date so that the sort works. I have tried using
    select TO_DATE(TO_CHAR(hd.PLANNED_IMPL_DATE, 'DD-MON-YYYY HH12:MI'), 'DD-MON-YYYY HH12:MI')mydate from table x however this now truncates the times.
    I do not want to alter the sessions. Is there any other way i can keep the times and so that the sort works?
    Thanks
    Monica

    Monica:
    Instead of applying the 'to_char' function to the date in the query, you could try setting the date-format mask for the column in the report's column attributes section.
    Report Attributes -> Column Attributes ->Column Formatting -> Number/Date Format
    Varad

  • Issue converting String to DateTime to subtract 1 Day duration  in XSLT

    Hi
    I need to subtract 1 Day duration from the input date which is in format "yyyy-mm-ddT00:00:00"( data type=String)
    I tried using the available function: subtract-dayTimeDuration-from-dateTime() But, this function expects input as datatype datetime and hence on using this I am getting Null as the result of the transformation.
    I have used dateTime() to convert the input string but it doesnt seem to be working as i get error "Invalid Xpath expression(null).
    Please help in identifying anyother way i can convert the String into dateTime format and hence subtract the duration. Or some other way of subtracting the duration of 1 day from string itself.
    Thanks for the help!

    Hi,
    It should work with the date on the format you have... Review the code, it may have some mistype... Also, in BPEL you should use the xp20 functions...
    Have a look at this...
    https://blogs.oracle.com/reynolds/entry/whats_the_time_mr_bpel
    Hope this helps...
    Cheers,
    Vlad

  • Converting String To XML Format and send as attachment

    Hi
    My requirement is to convert String into XML Format and that XML File i have to send as an attachment
    can any one one give solution for this Problem.
    Thank you
    Venkatesh.K

    hi,
    i m filling the itab first and converting to xml
    itab contaning these data
    GS_PERSON-CUST_ID   = '3'.
    GS_PERSON-FIRSTNAME = 'Bill'.
    GS_PERSON-LASTNAME  = 'Gates'.
    APPEND GS_PERSON TO GT_PERSON.
    GS_PERSON-CUST_ID   = '4'.
    GS_PERSON-FIRSTNAME = 'Frodo'.
    GS_PERSON-LASTNAME  = 'Baggins'.
    APPEND GS_PERSON TO GT_PERSON.
    after conversion data is coming like that
    #<?xml version="1.0" encoding="utf-16"?>
    <CUSTOMERS>
      <item>
        <customer_id>0003</customer_id>
        <first_name>Bill</first_name>
        <last_name>Gates</last_name>
      </item>
      <item>
        <customer_id>0004</customer_id>
        <first_name>Frodo</first_name>
        <last_name>Baggins</last_name>
      </item>
    </CUSTOMERS>
    but errors are  1) # is coming at the first
                            2)for 'encoding="utf-16"?>', it is not coming perfectly, some other data (iso-8859-1) should come here
    can anybody plz solve it.
    regards,
    viki

  • Converting string to XML format

    Hi All,
    I have a requirement to convert string to xml format and download it. Atpresent, I have a string which is a collection of xml tags. I want to convert this string to xml format like <VALUE004>20387899.437</VALUE004>
    <VALUE005>20387899.437</VALUE005>
    <VALUE006>20387899.437</VALUE006>
    Is there any function module for this.

    Chk this thread.
    Re: Regd: File Conversion to XML format

  • I want convert string to date format in Oracle

    Dear All
    I want convert string to date format in Oracle,Format is given below
    'Friday, 02 March 2012 2:44 PM' to '02/03/2012 2:44 PM'

    >
    Hi Parwez,
    I want convert string to date format in Oracle,Format is given below
    'Friday, 02 March 2012 2:44 PM' to '02/03/2012 2:44 PM'SELECT TO_DATE('Friday, 02 March 2012 2:44 P.M.', 'DAY, DD MONTH YYYY HH:MI A.M.') from dual;
    As well as what the other poster suggested, look here: http://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements004.htm#i34924
    HTH,
    Paul...

  • 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 string to Datetime?

    Hello all,
    I have seen tons of titles in this forum with the same like mine, but none of them helped solve my issue. It seems very simple, but it gives me a format exception. I am just trying to convert a string to datetime with a specified format.
    string convertToString;
    convertToString = (theWeek.AddDays(i).ToString("dd/MM/yyyy"));
    theDay = DateTime.ParseExact(convertToString, "dd'/'MM'/'yy", null),
    Here theDay is also a DateTime variable.
    These are the errors i get when I execute the code
    1. When converting a string to DateTime, parse the string to take the date before putting each variable into the DateTime object.
    2. When going into the details of the exception this is what I see " String was not recognized as a valid DateTime".
    Please advise!
    Thanks all.
    Thanks, Sumesh

    Thanks Ante & JayChase for the speedy response.
    I did it the way you mentioned and i was able to get rid of the exception, but still it doesn't show up in the specified format. It shows the time too which I am not asking for. 
    this is what I get now "3/17/2015 12:00:00 AM" .
    I just want 17/03/2015.
    Thanks again.
    Thanks, Sumesh
    I think I see the "problem" here.  I suspect that there isn't one.
    string convertToString;
    convertToString = (DateTime.Now.AddDays(5).ToString("dd/MM/yyyy"));
    DateTime day = DateTime.ParseExact(convertToString, "dd/MM/yyyy", null);
    This works perfectly, as it should.  You appear to have set a breakpoint someplace and you're examining the Visual Studio "value" of the variable 'day.'  You're unhappy that it displays in a manner that you don't like.
    I believe that you're simply not understanding the difference between a System.DateTime object and a System.DateTime represented as a string.
    To start with, a System.DateTime is a 64-bit integer value.  According to the MSDN documentation page:
    Time values are measured in 100-nanosecond units called ticks, and a particular date is the number of ticks since 12:00 midnight, January 1, 0001 A.D. (C.E.) in the
    GregorianCalendar calendar (excluding ticks that would be added by leap seconds). For example, a ticks value of 31241376000000000L
    represents the date, Friday, January 01, 0100 12:00:00 midnight. A DateTime value is always expressed in the context of an explicit or default calendar.
    When you call the DateTime.ToString() method and specify an output style, you get the 64-bit value in the human-readable string representation you want.  When you set a breakpoint and examine the variable in Visual Studio, you get the 64-bit value in
    the human-readable string representation Visual Studio provides by default.
    I hope this helps.
    Content Removed

  • Convert String to DATETIME

    Hi,
    I'm really struggling in converting a string which contains a dates to a DateTime datatype.
    below is an example of how it looks
    AdmissionDate
    29.09.14 08:52
    29.09.14 08:50
    29.09.14 08:06

    Hi Sam,
    you can use convert function to change the above string to datetime data type.
    select
    convert(datetime,'29.09.14 08:52',3)
    select
    convert(datetime,'29.09.14 08:50',3)
    select
    convert(datetime,'29.09.14 08:06',3)
    Thanks, RajaSekhara Reddy . K

  • Convert string to datetime and then use in a where clause

    I am trying to pull in warranty expiry dates that have been entered as strings and then perform a calculation as to which ones are expired, about to expire within
    90 days or will expire in more than 90 days. I have got the query to a point where I have converted it to a datetime field (though I'm sure I used the right value to just give me the date, its giving me date and time) and have it printing out the machine name
    and the warranty for that machine.
    SELECT
      machNameTab.machName
      ,convert(date,auditRsltManualFieldValues.fieldValue,103) AS warranty
    FROM
      machNameTab
      INNER JOIN auditRsltManualFieldValues
        ON machNameTab.agentGuid = auditRsltManualFieldValues.agentGuid
    WHERE
      machNameTab.groupName = N'root.company'
      AND auditRsltManualFieldValues.fieldNameFK = 958472722796011
    What I need to do next is change this so instead of just spitting out all the dates as 'Warranty', I want it to give me the fields 'Expired', 'Expiring' (expiry date is within 90 days of the current date) and 90Days (expiry date is over 90 days from the current
    date)

    SELECT
    machNameTab.machName
    ,convert(date,auditRsltManualFieldValues.fieldValue,103) AS warranty,
    select
    case
    when datediff(day,getdate(),convert(date,auditRsltManualFieldValues.fieldValue,103) )<90 then 'Expiring'
    when datediff(day,getdate(),convert(date,auditRsltManualFieldValues.fieldValue,103) )<0 then 'Expired'
    when datediff(day,getdate(),convert(date,auditRsltManualFieldValues.fieldValue,103) )>=90 then '90Days'
    end as status
    FROM
    machNameTab
    INNER JOIN auditRsltManualFieldValues
    ON machNameTab.agentGuid = auditRsltManualFieldValues.agentGuid
    WHERE
    machNameTab.groupName = N'root.company'
    AND auditRsltManualFieldValues.fieldNameFK = 958472722796011
    I added a case to your select. The case will output the strings you wanted based on the date.

  • How to convert string to date format?

    Hi All,
    String is in following format: 2006-12-07 i.e yyyy-mm-dd
    I want it in 07.12.2006 date format.
    which function module should i used to convert it?
    Regards,
    Nilima

    an other way to do this :
    Code
    DATA :
    ld_text(20) TYPE c,
    ld_date TYPE datum.
    ld_text = '2006-12-07'.
    REPLACE ALL OCCURENCES OF '-' IN ld_text WITH ''.
    WRITE ld_text TO ld_date.
    WRITE ld_date.

  • Convert string to datetime produces error

    Hi All,
       I am trying to convert a string to a datetime. When I use the formula below with an alias table, it gives me an error "Invalid Column Name c1.Date"
    SELECT CONVERT(datetime,left([c1.Date],2)'/'substring([c1.Date],3,2)'/'right([c1.Date],4),101) AS Date
    FROM callrecords c1
    Is there another way to convert the string to a datetime?
    I am using CR 2008 SP1.
    Thank you in advance.

    What happen if you run the sql without the conversion,
    SELECT c1.Date FROM callrecords c1
    do you still get the same error message?
    if you don't get the error message you can let crystal do the conversion for you  by using the following function in a formula
    CDate ({c1.Date})

  • Cast string as datetime issue

    I have installed SQL Server Express 2008 R2 on a Windows 7, language Brazilian-Portuguese ( PT-BR ). When I run a function which converts string to datetime it is raising conversion exception. I have tried the ANSI format 'yyyy-mm-dd' and 'mm-dd-yyyy', but
    the only one that works is 'dd-mm-yyyy'. Is there any kind of settup that should be made to reset SQL Server to the ANSI default ?
    Jayme Jeffman

    Datetime/string conversion:
    http://www.sqlusa.com/bestpractices/datetimeconversion/
    Starting with SQL Server 2012, TRY_CONVERT() is available for date validity check:
    http://beyondrelational.com/modules/2/blogs/70/posts/19841/data-validation-using-tryconvert-function.aspx
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Database Design
    New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014

  • Convert Char to Date format - Evaluate

    Hi,
    Could anyone provide us the Evaluate formula to convert Char to Date format
    2009-06-20 should be converted to 06/20/2009
    Regards,
    Vinay

    Hi,
    Refer the below threads...
    Re: How to convert string to date format?
    how to convert character string into date format????
    Regards,
    Chithra Saravanan

  • Conversion of String to Raw format

    How to Convert String to Raw format?

    Hi,
    Data : L_temp type string.
    Move 'TEST PROGRAM' to l_temp.
    Best regards,
    Prashant

Maybe you are looking for

  • Music on iPod to iTunes?

    I feel really stupid asking this but, is it possible to move music from an iPod onto iTunes? The reason I'm asking this is because my Aunt has a Fifth Generation iPod and she asked me to put a few episodes of lost (Downloaded with iTunes) onto her iP

  • No keyboard shortcuts for playing / resuming video clips?

    Are there any keyboard shortcut to play / resume video clips in the Photos app? It's super annoying needing to click on the play button every time I navigate to a new clip! If there's no way to do it now, are there any place we could submit feedback

  • BAPI_PO_CHANGE me22n add profit center for purchase requisition number

    Hello all, I have to add an item line for a specific sales order( p_vbeln ). for that i use BAPI_SALESORDER_CHANGE and it works and the item is inserted. ( p_posnr = sales order item and ln_etnr = schedule_line = 1 ) Now I have to maintain the specif

  • How to position a table to display at the bottom of the page using XSL-FO

    hi al, i have a set of codes that creates a table and displays on the first row of the page. i want it to display on the bottom of this page. how do i do that? example code i have is <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0

  • SCCM 2012 migrate server A to Server B.

    Right now I have BACKOFFICE running Windows 2008 R2 server which has SCCM 2012 SP1 installed and is in production. I did a newly installed of another primary stand alone SCCM 2012 SP1 on SCCMSERVER running Windows 2012 R2. My question are 1. What is