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

Similar Messages

  • 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

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

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

  • 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

  • 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

  • Urgent!!!!!! Issue with String in CO

    Hi All,
    I am learner of OAF.
    I have issue with string while converting into double.
    In AM,
    public String ComputeMarginPercent()
    retrun form.format((55570.0*100)/184.64999999999418);
    in CO..I am getting the value:
    String s1 = (String)oapagecontext.getApplicationModule(oawebbean).invokeMethod("computeMarginPercent");
    here getting value of s1=30,094.77
    I need to convert s1 to double, while converting double its raising error.
    how can I remove comman in (30,094.77) this number..?
    please advise me ..

    Hi Pratap,
    I am new to java ..
    Can you please tell me in step by step..?
    Thanks in advance
    I tried like /..
    String str= "30,094.77 ";
    char[] chars = str.toCharArray();
    String s = String.copyValueOf(chars);
    System.out.println(s);
    Still displaying value as 30,094.77 (with comma)
    Edited by: user633508 on Nov 21, 2008 2:55 AM

  • Convert String to java UTC date then to sql date

    Hi,
    I am trying to convert string (MM/dd/yyyy format) to UTC date time and store in the database.
    This is what I did:
    String dateAsString = "10/01/2007";
    SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
    formatter.setTimeZone(TimeZone.getTimeZone("GMT"));
    formatter.setLenient(false);
    java.util.date dateValue = formatter.parse(dateAsString, new ParsePosition(0));
    dateValue will be Sun Sep 30 20:00:00 EDT 2007 in UTC.
    Now I need to store this date and time to MS SQL database.
    I used the following code:
    java.sql.Date sqlDateValue = new java.sql.Date(parsedToDate.getTime());
    But this code give only the date, not time 2007-09-30
    Can anybody tell me how I can change this java date to sql date (or datetime?) so that I can get both date and time.
    Thanks,
    semaj

    semaj07 wrote:
    Hi,
    I am trying to convert string (MM/dd/yyyy format) to UTC date time and store in the database.
    This is what I did:
    String dateAsString = "10/01/2007";
    SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
    formatter.setTimeZone(TimeZone.getTimeZone("GMT"));
    formatter.setLenient(false);
    java.util.date dateValue = formatter.parse(dateAsString, new ParsePosition(0));
    dateValue will be Sun Sep 30 20:00:00 EDT 2007 in UTC.
    Now I need to store this date and time to MS SQL database.
    I used the following code:
    java.sql.Date sqlDateValue = new java.sql.Date(parsedToDate.getTime());
    But this code give only the date, not time 2007-09-30
    Can anybody tell me how I can change this java date to sql date (or datetime?) so that I can get both date and time.
    Thanks,
    semajTake a look at java.sql.Timestamp:
    http://java.sun.com/javase/6/docs/api/java/sql/Timestamp.html
    Edited by: hungyee98 on Oct 17, 2007 8:57 AM

  • Converting strings to the floating number and plotting

    Hello,
    I have a question regardting converting string of numbers to the floating bumbers and plot for voltage vs. weight.
    The load cell for the ADC resolution is 16 bits, and the voltage will be in between +-5 volts.
    The problem, I have the most is converting the string of numbers to the floating numbers, in my case is the weight.
    Attachments:
    tunnelv1.vi ‏139 KB

    When you say "string of numbers" do you mean an array? What is the specific issue you are having? You seem to have orange wires running all over the place. Give a small example demonstrating the problem.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • Converting varchar to datetime 103

    Hi Guys
    Im making a select query where in a colomn the date is yyyy-mm-dd, i need dd-mm-yyyy (103). A simple convert query does not work because the colomn is not set as a datetime but as a varchar. Its not possible to change the tables at the source.
    The colomn name is DATE_IN
    I think the following post could be helpfull but i dont know how to fix the given statements into the select query
    http://stackoverflow.com/questions/1509977/convert-varchar-into-datetime-in-sql-server

    > in a colomn the date is yyyy-mm-dd, i need dd-mm-yyyy (103)
    As suggested above, this is string date format to string date format conversion, purely string operations.
    If you convert to DATE / DATETIME first (universal internal binary representation), then it may fail if invalid date. 
    You can use the ISDATE or TRY_CONVERT functions to check if the string date is valid.
    DATETIME functions:
    http://www.sqlusa.com/bestpractices/datetimeconversion/
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Design & Programming
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • How to split the string by datetime in sql

    Hi,
    How to split the string by datetime in sql, I've a table with comments column stores comments by datetime, while selecting I want to split and show as in rows by each jobref.
    can anyone help me in this please.
    Thanks,

    declare @callcentre table (comments varchar(max),lbiref varchar(200))
    insert into @callcentre
    select '(28/10/2014 14:56:14) xyz ..... call  logged   (28/10/2014 14:56:58) xyz ..... call updated   (28/10/2014 14:57:41)xyz ..... call updated','Vi2910201'
    insert into @callcentre
    select '(29/10/2014 14:56:14) xyz ..... call  logged   (29/10/2014 14:56:58) xyz ..... call updated   (29/10/2014 14:57:41)xyz ..... call updated','Vi2910202'
    insert into @callcentre
    select '(30/10/2014 14:56:14) xyz ..... call  logged   (30/10/2014 14:56:58) xyz ..... call updated  
    output:
    1) 28/10/2014 14:56:14, (28/10/2014 14:56:14) xyz ..... call  logged ,'Vi2910201'
     2) 28/10/2014 14:56:58 ,(28/10/2014 14:56:58) xyz ..... call updated ,'Vi2910201'
    3) 28/10/2014 14:57:41,  (28/10/2014 14:57:41)xyz ..... call updated,'Vi2910201'
    4) 28/10/2014 14:56:14, (28/10/2014 14:56:14) xyz ..... call  logged ,'Vi2910202'
     5) 28/10/2014 14:56:58 ,(28/10/2014 14:56:58) xyz ..... call updated ,'Vi2910202'
    6) 28/10/2014 14:57:41,  (28/10/2014 14:57:41)xyz ..... call updated,'Vi2910202'
    7) 28/10/2014 14:56:14, (28/10/2014 14:56:14) xyz ..... call  logged ,'Vi2910203'
     8) 28/10/2014 14:56:58 ,(28/10/2014 14:56:58) xyz ..... call updated ,'Vi2910203'
    Thanks,
    See this illustration
    declare @callcentre table (comments varchar(max),lbiref varchar(200))
    insert into @callcentre
    select '(28/10/2014 14:56:14) xyz ..... call logged (28/10/2014 14:56:58) xyz ..... call updated (28/10/2014 14:57:41)xyz ..... call updated','Vi2910201'
    insert into @callcentre
    select '(29/10/2014 14:56:14) xyz ..... call logged (29/10/2014 14:56:58) xyz ..... call updated (29/10/2014 14:57:41)xyz ..... call updated','Vi2910202'
    insert into @callcentre
    select '(30/10/2014 14:56:14) xyz ..... call logged (30/10/2014 14:56:58) xyz ..... call updated','Vi2910203'
    SELECT LEFT(p.u.value('.[1]','varchar(max)'),CHARINDEX(')',p.u.value('.[1]','varchar(max)'))-1) AS [Date],
    '(' + p.u.value('.[1]','varchar(max)') AS comments,
    lbiref
    FROM
    SELECT lbiref,CAST('<Root>' + STUFF(REPLACE(comments,'(','</Data><Data>'),1,7,'') + '</Data></Root>' AS XML) AS x
    FROM @callcentre c
    )t
    CROSS APPLY x.nodes('/Root/Data')p(u)
    and the output
    Date comments lbiref
    28/10/2014 14:56:14 (28/10/2014 14:56:14) xyz ..... call logged Vi2910201
    28/10/2014 14:56:58 (28/10/2014 14:56:58) xyz ..... call updated Vi2910201
    28/10/2014 14:57:41 (28/10/2014 14:57:41)xyz ..... call updated Vi2910201
    29/10/2014 14:56:14 (29/10/2014 14:56:14) xyz ..... call logged Vi2910202
    29/10/2014 14:56:58 (29/10/2014 14:56:58) xyz ..... call updated Vi2910202
    29/10/2014 14:57:41 (29/10/2014 14:57:41)xyz ..... call updated Vi2910202
    30/10/2014 14:56:14 (30/10/2014 14:56:14) xyz ..... call logged Vi2910203
    30/10/2014 14:56:58 (30/10/2014 14:56:58) xyz ..... call updated Vi2910203
    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

  • 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

Maybe you are looking for