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})

Similar Messages

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

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

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

  • 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

  • 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

  • Error in converting String to XML file

    Hi
    Please see the code below, basically i want to convert the String
    i am having error when parsing xmlFile1, since the xml has some German characters like �
    How do i work around it or what is the best way to do it
    import javax.xml.parsers.*;
    import org.w3c.dom.*;
    import java.io.*;
    public class TestXMLFile
         public TestXMLFile() throws Exception
              DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            factory.setValidating(false);
              StringBuffer xmlFile = new StringBuffer();
              xmlFile.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
              xmlFile.append("<ITEMSPECIALNOTES><SPECIALNOTE>unvernderter Nachdruck</SPECIALNOTE></ITEMSPECIALNOTES>");
              ByteArrayInputStream byteArray = new ByteArrayInputStream(xmlFile.toString().getBytes());
            Document doc = factory.newDocumentBuilder().parse(byteArray);
              System.out.println ("String parsed in XML ");     
              StringBuffer xmlFile1 = new StringBuffer();
              xmlFile1.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
              xmlFile1.append("<ITEMSPECIALNOTES><SPECIALNOTE>unver�nderter Nachdruck</SPECIALNOTE></ITEMSPECIALNOTES>");
              ByteArrayInputStream byteArray1 = new ByteArrayInputStream(xmlFile1.toString().getBytes());
            Document doc1 = factory.newDocumentBuilder().parse(byteArray1);
              System.out.println ("String1 parsed in XML ");
         public static void main(String args[])throws Exception
             new TestXMLFile();
    }

    Don't convert to bytes using your system's default encoding but tell the parser that the bytes are encoded in UTF-8.
    In fact since you already have chars, don't convert to bytes and make the parser convert back to chars at all. Do this:String string = xmlFile.toString();
    Document doc =
       factory.newDocumentBuilder().parse(new InputSource(new StringReader(string)));

  • Jsp string of a datetime value error

    Hi all, I got this problem in one jsp recently, sql0181N String representation of a datetime value is out of range. However, this error just occur in recently, there is no such error before and the page can successfully loaded with proper function. And I didn't change the code of the related page so far, why leads to such problem. The page is just for displaying several years data, show the data week by week, that's why need the string of datetime value. And the page can successfully show all data for several months, so I would like to know why it suddenly has such error? Anyone can offer me a helping hand? Really thanks a lot.

    This is caused by an invalid date, which you may know, perhaps you changed the date format somewhere? or the locale on the page?
    so instead of 12/31/2008 being new years eve you might be trying 31/12/2008 which is invalid?
    just a thought.

  • Cannot convert string to date

    Hey Guys,
    I'm starting powershell and I'm having a headheck (I'm searching for hours) with a piece of code :)
    I'm trying to do that :
    $LogLines = (Get-Content -Path $LogPath)
    Foreach ($LogLine in $LogLines) {
    $LogSubString = $LogLine.Substring(21,15)
    [datetime]$date = $LogSubString
    But I have an error
    Cannot convert value "‎10‎-‎22‎-‎2014" to type "System.DateTime". Error: "String was not
    recognized as a valid DateTime."
    As you see, the value I read from a file is "10-22-2014".
    When I try this, it is working :
    $LogLines = (Get-Content -Path $LogPath)
    Foreach ($LogLine in $LogLines) {
    $LogSubString = "10-22-2014"
    [datetime]$date = $LogSubString
    So I don't understand why it's not working since "10-22-2014" and $LogLine.Substring(21,15) represents the same value but one is not working.
    Can someone please help me ? :)
    Cheers,
    Jeremie

    Get-Content has a parameter -Encoding UTF-8
    But I not sure that's the way to go, that could result in data loss / confusion
    Or take a good look at the string, leave $LogLine.Substring(21,15)
    as is.
    $LogLines = (Get-Content -Path $LogPath)
    Foreach ($LogLine in $LogLines) {
    $LogSubString = $LogLine.Substring(21,15)
    "LogSubString=$LogSubString"
    "LogSubString.Length=$($LogSubString.Length)"
    FOR ($I=0;$I -LT $LogSubString.Length;$I++)
    $Char = $LogSubString.Chars($I)
    "I=$I Char=$Char Int=$($Char -as [Int])"
    [datetime]$date = $LogSubString

  • Why does DB2 Data Flow Task query does not accept a date coming from a string or datetime variable in SSIS?

    I am trying to compare a DB2 date format to a date variable from SSIS. I have tried to set the variable as datetime and string. I have also casted the SQL date as date in the data flow task. I have tried a number of combinations of date formats, but no luck
    yet. Does anyone have any insights on how to set a date (without the time) variable and be able to use it in the data flow task SQL? It has to be an easy way to accomplish that. I get the following error below:
    An invalid datetime format was detected; that is, an invalid string representation or value was specified. SQLSTATE=22007".
    Thanks!

    Hi Marcel,
    Based on my research, in DB2, we use the following function to convert a string value to a date value:
    Date(To_Date(‘String’, ‘DD/MM/YYYY’))
    So, you can set the variable type to String in the package, and try the following query:
    ACCOUNT_DATE  BETWEEN  '11/30/2013' AND  Date(To_Date(?, ‘DD/MM/YYYY’))
    References:
    http://stackoverflow.com/questions/4852139/converting-a-string-to-a-date-in-db2
    http://www.dbforums.com/db2/1678158-how-convert-string-time.html
    Regards,
    Mike Yin
    TechNet Community Support

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

  • 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 in xslt

    Hi we are trying to convert string to xml in xslt but it is getting errored out.
    We have followed the procedure mentioned at http://download.oracle.com/docs/cd/A91202_01/901_doc/appdev.901/a88894/adx04xsl.htm under the section "How Do I Convert A String to a Nodeset in XSL?".
    Standard procedure mentioned by oracle is not working. Is it a known bug?

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

Maybe you are looking for

  • Updating table

    hi friends, i have one table in my application. i will update cells by enetering data into it. here the problem is after i typed digits i need to press ENTER or i need to press TAB to update the entered value into table cell. is there any way that wi

  • BW showing Negative Material Valuated stock value !

    Experts, in BW i am i am getting all Negative valuated stock value for all material. can anybody suggest what could be the issue ? in R/3 if the valuated value is $100, then in bw its showing the same value but Negative. please help

  • OIM DB columns to get user events

    Hi, Can we capture the events from OIM database tables - New Joiner, Leaver, Modified User and certain fields based on these events Using BIPublisher integrated with OIM, can we consolidate above 3 events in a report and print all the users which are

  • ITunes visualizer causes Mac Mini to crash

    When I run iTunes visualizer on full screen, after a while (about an hour into playing) it causes my whole system to crash. I thought it was the mac mini at first (because a friend of mine ran his macbook pro with itunes visualizer and it never crash

  • What is Item Category in SAP CRM ? Where exactly it will be useful ?

    What is Item Category in SAP CRM ? Where exactly it will be useful ?  Please explain in detail. Edited by: Rajanand Tadakamadla on Nov 6, 2010 12:46 PM