DBDatasource Date Value to Datetime

Hi,
I get a string representation of a date field using DBDataSource.GetValue("U_Date",0)
I get for example: "20070503" What type of format is this?
What is the simplest way to convert this to a standard DateTime variable?
.Ben

Hi Ben,
The datasource value will always be in the format yyyyMMdd. With that you can always do (VB .NET)
Dim dDate as Date
dDate = New Date(sDate.Substring(0, 4), sDate.Substring(4, 2), sDate.Substring(6, 2))
without needing to worry about regional settings.
If you need formatting from and to real date strings, you could use the SboBOB object methods, Format_DateToString and Format_StringToDate. There are some SDK examples about this.
Hope this helps,
Ian

Similar Messages

  • Script Data Component - System.DateTime.TryParseExact Method not validation date value

    Hello
    I have Script data component in my data flow task and i am trying to validate whether the date fields has valid date values or not.
    So i added below code to validate the date fields
    in below code TestDate is datetime and ValidTestDate is datetime as well.
    string[] formats = { "MM/dd/yyyy", "MM/d/yyyy", "M/dd/yyyy", "M/d/yyyy"};
    DateTime pDateTime;
    if (System.DateTime.TryParseExact(Row.TestDate.ToString(), formats, CultureInfo.InvariantCulture, DateTimeStyles.None, out pDateTime)==true)
                    Row.ValidTestDate = Row.TestDate;
    System.DateTime.TryParseExact is not validating to true even the TestDate is valid.
    I have even tried converting the datetime field to DT_DATE but it did not work.
    I appreciate any suggestion to accomplish the check whether it is valid date or not.
    Regards
    Harris

    This is because the string value of TestDate does not conform to either of the formats.
    Arthur
    MyBlog
    Twitter

  • "Data truncation: Incorrect datetime value" Error Message

    Hello,
    I'm running Coldfusion 8 with a MySQL database. The s10Date
    column is of type "datetime".
    What would cause the following error to occur when I'm
    entering data into the database?
    Data truncation: Incorrect datetime value: '{ts '2008-09-03
    17:16:01'}' for column 's10Date' at row 1
    The error occurred in
    C:\ColdFusion8\wwwroot\Websites\questnbs.info\components\DataMgr\DataMgr.cfc:
    line 1602
    Called from
    C:\ColdFusion8\wwwroot\Websites\questnbs.info\components\DataMgr\DataMgr.cfc:
    line 1170
    Called from
    C:\ColdFusion8\wwwroot\Websites\questnbs.info\components\DataMgr\DataMgr.cfc:
    line 1633
    Called from
    C:\ColdFusion8\wwwroot\Websites\questnbs.info\parsed\quest_c_registrations.processregistr ationform.cfm:
    line 37
    Called from
    C:\ColdFusion8\wwwroot\Websites\questnbs.info\parsed\quest_c_registrations.processregistr ationform.cfm:
    line 5
    Called from
    C:\ColdFusion8\wwwroot\Websites\questnbs.info\parsed\quest_c_registrations.processregistr ationform.cfm:
    line 1
    Called from
    C:\ColdFusion8\wwwroot\Websites\questnbs.info\fusebox5\Application.cfc:
    line 228
    Called from
    C:\ColdFusion8\wwwroot\Websites\questnbs.info\fusebox5\Application.cfc:
    line 218
    Called from
    C:\ColdFusion8\wwwroot\Websites\questnbs.info\fusebox5\fusebox5.cfm:
    line 57
    Called from
    C:\ColdFusion8\wwwroot\Websites\questnbs.info\index.cfm: line 12
    1600 : <cfquery name="qQuery"
    datasource="#variables.datasource#" username="#variables.username#"
    password="#variables.password#"><cfloop index="i" from="1"
    to="#ArrayLen(aSQL)#" step="1"><cfif IsSimpleValue(aSQL
    )><cfset temp =
    aSQL>#Trim(PreserveSingleQuotes(temp))#<cfelseif
    IsStruct(aSQL
    )><cfset aSQL = queryparam(argumentCollection=aSQL
    )><cfswitch
    expression="#aSQL.cfsqltype#"><cfcase
    value="CF_SQL_BIT"><cfif aSQL
    .value>1<cfelse>0</cfif></cfcase><cfcase
    value="CF_SQL_DATE">#CreateODBCDateTime(aSQL.value)#</cfcase><cfdefaultcase><cfif
    ListFindNoCase(variables.dectypes,aSQL
    .cfsqltype)>#Val(aSQL.value)#<cfelse><cfqueryparam
    value="#aSQL
    .value#" cfsqltype="#aSQL.cfsqltype#" maxlength="#aSQL
    .maxlength#" scale="#aSQL.scale#" null="#aSQL
    .null#" list="#aSQL.list#" separator="#aSQL
    .separator#"></cfif></cfdefaultcase></cfswitch></cfif>
    </cfloop></cfquery>
    1601 : <cfelse>
    1602 : <cfquery name="qQuery"
    datasource="#variables.datasource#"><cfloop index="i"
    from="1" to="#ArrayLen(aSQL)#" step="1"><cfif
    IsSimpleValue(aSQL)><cfset temp = aSQL
    >#Trim(PreserveSingleQuotes(temp))#<cfelseif
    IsStruct(aSQL)><cfset aSQL
    = queryparam(argumentCollection=aSQL)><cfswitch
    expression="#aSQL
    .cfsqltype#"><cfcase value="CF_SQL_BIT"><cfif
    aSQL.value>1<cfelse>0</cfif></cfcase><cfcase
    value="CF_SQL_DATE">#CreateODBCDateTime(aSQL
    .value)#</cfcase><cfdefaultcase><cfif
    ListFindNoCase(variables.dectypes,aSQL.cfsqltype)>#Val(aSQL
    .value)#<cfelse><cfqueryparam value="#aSQL.value#"
    cfsqltype="#aSQL
    .cfsqltype#" maxlength="#aSQL.maxlength#" scale="#aSQL
    .scale#" null="#aSQL.null#" list="#aSQL
    .list#"
    separator="#aSQL.separator#"></cfif></cfdefaultcase></cfswitch></cfif>
    </cfloop></cfquery>
    1603 : </cfif>
    1604 :
    Thank you in advance for your assistance.
    Simon

    Just a note, I had the same problem and resolved it by making
    sure my cfsqltype in cfqueryparam is cf_sql_timestamp instead of
    cf_sql_datetime (which is not a valid value).
    Also, just a note that when working with a datetime value in
    cfqueryparam, using cf_sql_date for cfsqltype will truncate the
    time to 00:00:00.

  • How to pass date value to an UDF

    Hi,
    I am working in SDK UI. I have created a form. In this form there is a edit text box. I have to pass a date value to that object. I have taken a variable and pass a date value in "yyyy/mm/dd" format. When I am assign this variable to the object to pass the date value to that object then I am getting an error. The error is "Unable to cast object of type 'system.string' to 'system.IFormatProvider' ".
    I have written the code like this :------>
    Dim AtenDate As String   
    AtenDate = '2007/08/01'    ' format "yyyy/mm/dd"
    Dim txtEditDt As SAPbouiCOM.EditText
    oItem = oForm.Items.Item("11")
    txtEditDt = oItem.Specific
    txtEditDt.String = AtenDate.ToString("dd/MM/yyyy")
    After the last line the error is getting fire.
    Please help me how I can pass the date value to that object.
    Please help me. It is very urgent.

    Date and Double conversion is really a confusing thing in B1-SDK programming in the beginning.
    But once you got it it's okay.
    When working with date-time and doubles (System and SBO-Price/SBO-Quantity),  you should always take care about the language of...
    ...system (windows)
    ...SBO User Interface
    These two formats could make trouble when the programming has been made only for a specific configuration of these two.
    The third format for SDK-Programming is
    ...the SBO-DB-Format, which is language-independent and always a String
    Here are some rules:
    <b>EditText.String</b> ALWAYS returns the value you see on the SBO GUI. It depends on the SBO Date, Price etc.-Format the USER has configured in the Administration. Consider that the user has (for example) the possibility to choose a "#" (or whatever) as decimal-seperator. Direct (implicit) conversion of such a string to a double will fail at the latest now.
    The savest way to get a .NET-Double or DateTime- Value from EditText.String are the conversion methods of  SBOBobs-Object (see SDK-help -> BoBridge, Format_MoneyToString...etc.).
    I think it's a good idea to write some wrapper functions for that methods, cause they always need a recordset which blows up the code too much.
    <b>EditText.Value</b> always (system/sbo-language independent) returns the value as a String in DB-Format (Double as "12345.126700" and date as "20070930".
    For that you must asure that the EditText is bounded to a format-corresponding datasource. Price, Quantitiy.... if you need a double.
    If your "price"-field would be bound to ShortText and the user wants (assuming the example from above) a "#" for decimal-point, then a GUI-seen value like "12,421#12" is also returned as "12,421#12" by EditText.Value. But If bound to Price-DataSource it's "12421.120000"
    => So always do a DataBind to the Data - Type which is needed is recommended for this to work!
    In my case EditText.String and -Value is mostly (only...? needed for B1-System-Forms where using of DataSources is restricted.
    The prefered way of read/write values is the
    <b>UserDataSource.ValueEx and DBDataSource.GetValue/SetValue</b>-method. It's also always in DB-Format as EditText.Value before, but gives much more performance.
    Once you got some conversion-functions for "DB-Format-String" to ".NET-DataType" and vice verca (I've defined some .NET - System.Globalization.XXXFormatInfo-Objects for that) all of your problems are things of the past
    Regards,
    Roland
    null
    Message was edited by:
            Roland Toschek
    Edited by: Roland Toschek on Jan 22, 2008 5:32 PM
    Trying to clarify a sentence

  • How to enter a date value in a Temporary Table

    Hi!
    Could anyone explain to me how I can enter a date value (say 26 October 2011) in a Temporary Table?
    I tried the simple example below, but it gives the foll. error message:
    Conversion failed when converting date and/or time from character string
    CREATE TABLE Temp1
    Column_A date,
    Column_B varchar(max)
    Insert into Temp1
    values ('26.10.2011', 'bbb')
    Thanks
    Leon Lai

    Hi,
    Try This.....
    CREATE TABLE Temp1
    Column_A datetime,
    Column_B varchar(max)
    Insert into Temp1
    values ('10/26/2011', 'bbb')
    Thanks
    Shafi

  • How to convert a date value into week value?

    How to display the date value like '20010203'
    into the week number of the year 2001?
    When i type in the following sql
    select week(chg_time) from site;
    I got this error message
    ORA-00904: invalid column name

    use the to_char function, to format the date into a week number (then you might need to convert that to a number using to_number)
    select to_char( sysdate, 'WW') from dual`
    a description of datetime formats: http://download-west.oracle.com/otndoc/oracle9i/901_doc/server.901/a90125/sql_elements4.htm#48515

  • Sending Date value to SAP R/3

    Hi,
        I am trying to send Date value from Text box (javascript) to SAP R/3 thru transaction and BAPI. But it is not accepting it. In SAP it accepting time value but it is not accepting date value. It take default date (current system date).
    But when we give date value directly in transaction it accepts.
    what is the problem. how to solve it?
    Regards,
    Senthil

    Your text box is a string.  If you assign it to a Local (or Transaction) Property of type DateTime, xMII may properly interpret it and allow the DateTime value to be populated.  However when you try to map it to SAP, it will most likely fail as it is of datatype DateTime (which is actually xml datetime).  You can assign the text box value to a Local Property with datatype String and format it from there.  Or if your Local Property is correctly interpreting the string from the text box and is updated, then you can explicitly convert from xml datetime to string type.
    functions which might be of interest or applicable are:
    datefromxmlformat
    dateformat
    stringpart
    Good luck,
    Mike

  • How to insert the Formatted date value and insert into the database

    Hi All,
    I am having requirement of inserting the date value in to the datbase. I'm already getting the value from file as MM-DD-YYYY. Getting exception while transforming the values through the transform activity. I'm using format fate function but it is inserting null value in to the database.
    Any help from anyone would bve appreciated.
    Thanks,
    CH

    Hi,
    your input date format is fixed right? So, in the transform you can split each your date, which is in 'MM-DD-YYYY' format ... extract day, month, year.
    After that ... just put these values in order acording to the format of 'xsd:date' data type which is '[-]CCYY-MM-DDZ'.
    XPath function 'xp20:format-dateTime()' works only with 'xsd:dateTime' data type, which has format '[-]CCYY-MM-DDThh:mm:ssZ'.
    So, in your case it could be:
    <xsl:variable name="day" select="substring($inputDate,4,2)"/>
    <xsl:variable name="month" select="substring($inputDate,1,2)"/>
    <xsl:variable name="day" select="substring($inputDate,7,4)"/>
    <xsl:variable name="outputDate">
    <xsl:value-of select="$year"/>
    <xsl:text>-</xsl:text>
    <xsl:value-of select="$month"/>
    <xsl:text>-</xsl:text>
    <xsl:value-of select="$day"/>
    </xsl:variable>
    Regards,
    Martin.

  • Can I convert Facebook time Text to Project Siena's Date value ?

    Can I convert Facebook time Text to Project Siena's Date value ?
    I want to show create_time on screen by my Localtime formatted text.
    Facebook time Text = 2014-07-14T11:22+0000
    I want to show = 2014/07/14 18:22
    My Time Zone is +09:00, Osaka/Japan.
    Currently I try it by Text/Replace/Replace/Replace/Left/DateValue/+ , etc.
    And I ask more simple way.
    Regards,
    Yoshihiro Kawabata

    Thank you Andy , and Robin, I can.
    Text(TimeValue(Substitute(ThisItem!created_time,"+0000",".000Z")),"yyyy/mm/dd hh:mm")
    At Facebook Albums's Gallary, I can convert from Facebook created_time to Localtime Text DateTime.
    and I hope more easy way like Excel Power Query's one.
    Regards,
    Yoshihiro Kawabata

  • How to set a date value at netui:hidden/ tag bind to a RowSet item/property through a form bean?

    Hi,
    I have the following urgent problem.
    I created a pageflow which uses a form bean (created with a db control) to insert
    values in a table. I overcame the disability to insert date values in the table
    by converting this columns to string values in the table. But now I have to insert
    a sysdate in a column that holds the row sampled date. How is it possible? I used
    javascript without an success.
    Code in jsp:
    document[getNetuiTagName("myForm",this)][getNetuiTagName("date",this)].value=new
    Date();(have used string values too)
    <netui:hidden dataSource="{actionForm.sampled}" tagId="date"/>
    Code in .jcx file
    <xsd:element name="SAMPLED" type="xsd:dateTime" wld:JDBCType="DATE" minOccurs="0"
    wld:TableName="theTable" nillable="true">
    * </xsd:element>
    Code in .jpf file
    * <pageflow-object id="formbeanprop:portlets.Career.Submit_CV.Submit_CVController.DatabaseForm#sampled#java.sql.Timestamp"/>
    public static class DatabaseForm extends RowSetForm
    public java.sql.Timestamp getSampled()
    return sampled;
    public void setSampled(java.sql.Timestamp newOne)
    registerChange("sampled");
    this.sampled = newOne;
    I have tried to use java.sql.Date too...
    Any help would be very appreciated.
    Thx,
    Vincent

    Hi,
    Hope You're using the template.fmb.
    If  your Custom Form is in INV module, use  'FND_ORG.CHOOSE_ORG;' in the pre-form.
    Else Set the org id dynamically,
    begin
        MO_GLOBAL.SET_POLICY_CONTEXT(ACCESS_MODE,ORG_ID);
    end;
    Example:
    begin
        MO_GLOBAL.SET_POLICY_CONTEXT('S',101);
    end;
    S - Denotes that the current session will work for Single Org_id (101)
    M - Denotes that the current session will work for Multiple Org_id
    Thanks

  • Need milli seconds part in XSLT Date Function  current-dateTime()

    Hi All,
    I am calling date function, current-dateTime() in XSL. The output format is 2012-04-05T16:38:01-07:00 (Without milli seconds)
    How to get the milli seconds part...?
    Regards,
    Sudheer

    Hi Arik....
    At last i got it. :)
    Followed the below steps.
    Step1:
    Created a String variable "currentDateTimeValue" in BPEL.
    Step2:
    I have used the below code in JavaEmbedding in BPEL.
    java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat();
    //Date Pattern looks lil weird. But some Web service accepts only this format.
    sdf.applyPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'-00:00'");//2012-04-14T16:24:00.578-00:00
    String formattedDate = sdf.format(new java.util.Date());
    addAuditTrailEntry("Formatted datetime string is: " + formattedDate);
    setVariableData("currentDateTimeValue", formattedDate);
    Step3:
    Created a Simple XSD with an element "DateElement" of String type.
    Step4:
    Assigned "currentDateTimeValue" value to "DateElement" element, in Assign activity.
    Step5:
    Now added this DateElement in Transformation activity, as a second source variable. Mapped this data to the required target element in my XSL.
    uh-huh I got the output...
    Thanks a ton ARIK :D u r really helpful...
    Regards,
    Sudheer

  • How to insert date value into oracle?

    hi,
    iam reading date from xml using vb.net and inserting it into oracle table.
    the date value in xml file is in the format of "01012003".
    i want to insert into oracle table.but iam getting an error "ORA-1843: not a valid month".
    how to solve this problem.
    Any suggestions or examples...

    That's not a date. It's just a string. Convert it to a date using,
    DateTime d = DateTime.ParseExact("01022003", "MMddyyyy", null);
    or
    Dim d As DateTime = DateTime.ParseExact("01022003", "MMddyyyy", Nothing)
    and then bind it to a parameter. ODP.NET will take it from there.
    You should never be hard-coding the date literal into your SQL query.
    David

  • Epubcheck fails to validate ID CS 5 date value

    Hello,
    I applied for an appication with Apple to distribute my ebook via their iBookstore. In Apple's specifications it says my epub file "Must" past epubcheck 1.0.5. I downloaded epubcheck and ran the code in Terminal. There was a minor hyperlink error, which I've fixed, however, I can not get rid of the following error.
    epubcheck 1.0.5
    ERROR: /Users/Digital/Desktop/XXXX-eBook.epub/OEBPS/content.opf(2): date value '' is not valid, YYYY[-MM[-DD]] expected
    Thinking that it could be an epubcheck program error I downoaded the newer version...
    epubcheck 1.1
    ERROR: /Users/Digital/Desktop/XXXX-eBook.epub/OEBPS/content.opf(2): date value '' is not valid. The date must be in the form YYYY, YYYY-MM or YYYY-MM-DD (e.g., "1993", "1993-05", or "1993-05-01"). See http://www.w3.org/TR/NOTE-datetime.
    I've done some research and found this fix:
    Troubleshooting the epub’s ‘date’ metadata
    (http://ebw.co/kbase/creating-epub-from-indesign/after-indesign-export-to-epub/add-metadata)
    If you check your epub with epubcheck version 1.0.5 or later, you may get this error message:
    ERROR: title.epub/OEBPS/content.opf(2): date value '' is not valid, YYYY[-MM[-DD]] expected
    To fix the date: in the metadata section of your content.opf file, replace this code
    <dc:date/>
    with this
    <dc:date>2010-06</dc:date>
    That date’s an example, of course. Change that to your publication  date. (If you don’t have a <dc:date/> tag, just add the line.)
    So now the question - why does ID CS 5 not output the date properly, and how do I open the opf file to insert the corrected code? Or is there another way - or have I failed to insert a date somewhere in my ID file. If so...where do I do that?
    Thanks.

    Ok, I got it fixed. I found this article: http://www.webvivant.com/fixing-InDesign-epub-2.html
    "...As content.opf is just a plain text file, you can open it with your  favourite text editor. Make sure you use a text editor and not a word  processor - you want something that can save ordinary text files."
    I opened the content.opf file in TextEdit and found the <dc:date/> empty as epubchecker suggested. I replaced it with this: <dc:date>2011-03</dc:date>
    I opened my eBook file with Springy (http://www.springyarchiver.com) and replaced old content.opf with the newly saved file. Ran epubcheck again in Terminal and got these results.
    No errors or warnings detected
    Hope this helps someone in the future...

  • [Forum FAQ] How do I have Invoke-SqlCmd return a date value without adding time

    Introduction
    A select statement executed from Invoke-SqlCmd returns a value from a Date column, the value has "12:00:00 AM" appended.  The same select statement executed within SQL Server Management Studio displays the date properly without any time formatting.
    Sample data is as follows:
    How to have Invoke-SqlCmd return Date values without adding time for multiple Date type columns and pipe the output into CSV file?
    Solution
    In SQL Server 2012 or onwards, use the FORMAT() function to convert datetime values to date format when executing query from Invoke-SqlCmd. In earlier versions such as SQL Server 2008 R2, use the traditional CONVERT() function to format datetime values to
    different date formats(yyyy.mm.dd, mm/dd/yyyy, etc) when executing query from Invoke-SqlCmd. Then pipe the output of SQL query result into CSV file by specifying export-csv parameter. An example is as follows.
    Create a table named “Test_invokesqlcmd” that contains Date type columns in SQL Server.
    USE Test
    Go
    CREATE TABLE [dbo].[Test_invokesqlcmd](
        [id] [int] NOT NULL,
        [name] [varchar](20) NULL,
        [test1] [date] NULL,
        [test2] [date] NULL
    ) ON [PRIMARY]
    GO
    insert into [dbo].[Test_invokesqlcmd]
    values(1,'David','2014-10-15','2015-01-07'),(2,'Jane','2011-08-05','2012-11-7'),(3,'Crystal','2013-09-15','2010-02-24')
    Define a query string, execute it from Invoke-SqlCmd and save the query result to a CSV file.
    Scripts for SQL Server 2012:
    $query1 = @"
        use Test;
        SELECT FORMAT(test1,'d') as newtest1, FORMAT(test2,'d') as newtest2 from dbo.Test_invokesqlcmd
    write-host $query1
    Invoke-Sqlcmd -Query $query1 -ServerInstance localhost | export-csv -notypeinformation -path c:\Files\test.csv
    Scripts for SQL Server 2008 R2:
    $query2 = @"
        Use Test;
        SELECT CONVERT(varchar, test1, 102) as newtest1,CONVERT(varchar, test2, 102) as newtest2
        FROM dbo. Test_invokesqlcmd
    write-host $query2
    Invoke-Sqlcmd -Query $query2 -ServerInstance localhost | export-csv -notypeinformation -path c:\Files\test.csv
    Check the results in SQL Server PowerShell window and csv file.
    SQL Server 2012:
    SQL Server 2008 R2:
    Reference
    Using the Invoke-Sqlcmd cmdlet
    SQL Server Functions that helps to convert date and time values to and from string literals and other date and time formats
    Applies to
    SQL Server 2014
    SQL Server 2012
    SQL Server 2008 R2
    SQL Server 2008
    Please click to vote if the post helps you. This can be beneficial to other community members reading the thread.

    Cross posted. More appropriate in JSF forum so continue conversation there.
    http://forum.java.sun.com/thread.jspa?threadID=717292&messageID=4142615#4142615

  • 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

Maybe you are looking for