Wrong date value is inserting

Hi All!
When I call the procedure insertDate that inserting the date it inserts wrong value, sometimes the date is more than a year off, otherwise the value of new Timestamp(date.getTime()) is giving the right date at the moment of setting the parameter.
Why is it happening and how to fix that?
Here is the source:
private static Date formatDate(int year, int mon, int mday, int hour, int min, int sec) {
Date date = null;
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String textDate = (1900 + year) + "-" + mon + "-" + mday + " " + hour + ":" + min + ":" + sec;
System.out.println(textDate);
try {
date = format.parse(textDate);
System.out.println(date.toString());
} catch (ParseException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
return date;
Date date = formatDate(111, 6, 29, 12, 59, 45);
CallableStatement cs = connection.prepareCall("{ call insertDate(?)}");
cs.the pasetTimestamp(1, new Timestamp(date.getTime()));
Thank you!
Regards,
Astrid

I'm using MySQL.
If I store Timestamp mostly I got '0000-00-00 00:00:00' and sometimes something like '2013-11-08 15:09:46'.
I've made changes in order to insert not Timestamp directly, but string. And it works properly by inserting exact date and time - '2011-07-01 08:29:33'.
My procedure now looks like
CREATE PROCEDURE `saveQueryResult`(date1 VARCHAR(50))
BEGIN
     DECLARE d DATETIME;
     SET d = TIMESTAMP(date1);
     INSERT INTO values_ (submit_date)
     VALUES (d);
END$$
DELIMITER ;

Similar Messages

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

  • Wrong date value in Essbase ASO cube

    Hi All,
    I'm trying to load a date value in mm-dd-yy format into an Essbase ASO cube. I'm using is a txt tab delimited file. The load rule is working fine. The outline properties is set with the proper format "mm-dd-yy". I loaded the data and when I retrieve the data using Smart View I see all the dates decreased by one day in my Smartview report.
    Would you have any ideas why that is happening?
    Thanks

    this is a bug and fixed in 11.1.2

  • Setting data values on insert with a form

    I have a form I am using to insert records into a table, and I want to be able to set the value for a certain column ( in this case status) to be dependent on the a value that another column is set to. The specific case here is I have an application users table so if I get a request for a user asking for lookup privilege I want to status field to be set to approved other requests should have status set to pending.
    I have tried adding a process and doing an update to the status based on the value of the role, but it seems that the role is null when it gets to the process. I am merely referencing the column of the form. In this case :P7_ROLE.
    Any help would be appreciated.
    John

    For anyone who looked at this, I found my problem. The process I created was at the wrong sequence and was executed after the page cache was cleared.
    Newbie mistake:)

  • Wrong data values displayed for YTD in reports

    Hi,
    In my reports when i try to select measures as YTD, eg. March 2010 YTD, i get wrong values for entities. But, apart from YTD, i get absolutely correct values if i select measures as anually, quarterly or monthly.
    I have checked ISBEGINNING property in time dimension and assigned values as 0 and 1 for the respective values. I have also checked if i have any wrong statements in dbo.measureformula in SQL server Management studio which might give wrong calculations but could not find any.
    Please guide me through.
    Many thanks in advance.
    Regards,
    Poonam

    HI Nilanjan,
    Thanks for your suggestions but i do not have any data in Apshell to test if it is being displayed correct or not.
    Please advice me further.
    Regards,

  • Incorrect data value when insert into oracle table

    Would like to ask expert here, how could I insert data into oracle table where the value is 03 ? The case is like that,  the column was defined as varchar2(50) data type, and I have a csv file where the value is 03 but when load into oracle table the value become 3 instead of 03.

    user11432758 wrote:
    Would like to ask expert here, how could I insert data into oracle table where the value is 03 ? The case is like that,  the column was defined as varchar2(50) data type, and I have a csv file where the value is 03 but when load into oracle table the value become 3 instead of 03.
    implicit datatype conversion to NUMBER can result in leading zero to be eliminated.
    How do I ask a question on the forums?
    https://forums.oracle.com/message/9362002#9362002

  • Format of Date Values in a Condition...Please Help!

    Hi,
    I just downloaded Oracle 11g XE and built an Oracle 11g XE database and is using the Application Express included to build simple reports. I used the Query Builder inside APEX and entered a condition on a Date column as BETWEEN '01-SEP-2011' AND '01-SEP-2012' and it gave me the error of the wrong data value, something like DATE expected. The actual values of that column are such as, 01-DEC-02, and there are no issues with the data column.
    This method has been working with the Query Builder in Oracle 10g. The generated SQL in this APEX is the same as the generated SQL in the query builder of 10g.
    I also tried different things, such as using 11 instead of 2011, removing the single quotes, etc. None has worked.
    Can someone tell me what is the correct way to key in a condition when the user wants to specify a date range?
    Thanks!

    Can you try like BETWEEN TO_DATE('01-SEP-2011', 'dd-mm-yyyy')?

  • Not getting proper date values for original GI Date

    Hi,
    I have to Calculate Original GI Date based on Original promise Date and transport Date(Original GI Date = Original promise Date-transport Date) and I am getting Original Promise date as"21112008" and transport date as"20112008". when I subtract in Update rules as formula as (Original promise Date-transport Date) getting Original GI DATE as"01000001" as it is giving wrong date values.please help me whether i am going right way or is there any thing else i have to select in Update rule level (formula) to get proper date values or how can i approach to get original GI date.
    it is QUITE Urgent...please help any one to solve the Issue.
    REGARDS
    VENKAT.

    Hi Venkatesh,
    Please search SDN forum before you post any questions. There are lots of threads available for this scenarios.
    Use formula variables in Bex in order to achieve your requirement. 
    Links below, may be helpful:
    Formula variable with replacement path on system date
    How to creae days count variable in SAP BI-BEx
    http://help.sap.com/saphelp_nw70/helpdata/en/f1/0a56a7e09411d2acb90000e829fbfe/frameset.htm
    Regards,
    Ravi Kanth.

  • DateField component in UIX  is rendering wrong date

    Hi,
    After the DST has ended, our bc4j:uix component is rendering wrong date values for alle the dates prior to 25.10.2009.
    We have following configuration
    UIX version: 2.2.24.2
    Jdev: 10.1.2.2.0 (build 1929)
    Our UIX application is deployed to a Linux server with the uix libraries comes with 2.2.24.2
    We have tried to upgrade to Uix version 2.2.24.5 as mentioned in the Bug 7631416 but it didn't solve the problem.
    Any help appreciated.
    Regards
    Mayu

    Okay, I think I have found a work around. Thanks anyways guys!
    Regards,
    John

  • SQL Loader-How to insert -ve & date values from flat text file into coloumn

    Question: How to insert -ve & date values from flat text file into coloumns in a table.
    Explanation: In the text file, the negative values are like -10201.30 or 15317.10- and the date values are as DDMMYYYY (like 10052001 for 10th May, 2002).
    How to load such values in columns of database using SQL Loader?
    Please guide.

    Question: How to insert -ve & date values from flat text file into coloumns in a table.
    Explanation: In the text file, the negative values are like -10201.30 or 15317.10- and the date values are as DDMMYYYY (like 10052001 for 10th May, 2002).
    How to load such values in columns of database using SQL Loader?
    Please guide. Try something like
    someDate    DATE 'DDMMYYYY'
    someNumber1      "TO_NUMBER ('s99999999.00')"
    someNumber2      "TO_NUMBER ('99999999.00s')"Good luck,
    Eric Kamradt

  • Problems inserting date values in Oracle 10g

    Hi All,
    I'm having SERIOUS problems trying to insert a simple date value in my oracle.
    I did this one million times before in xMII 11.5, but now it appears that doesn't work anymore!
    Here are some info:
    Data Server Config:
    Date Prefix: TO_DATE('
    Date_Sufix: ', 'MM/DD/YYYY HH24:MI:SS')
    Internal Date Format: yyyy-MM-dd HH:mm:ss
    In my Query Template:
    Date and Time Format: MM/dd/yyyy HH:mm:ss
    In my Transaction
    Parameter: datefromxmlformat(datenow, "MM/dd/yyyy HH:mm:ss")
    I also tried change the parameter to datenow, no success.
    I tried to change the Query Template format, no success.
    Finally, I tried to change my Date prefix & sufix, no success too.
    I really don't know what else I can do. I would appreciate some help.
    PS: I'm using xMII 12.0.1 with ojdbc14.jar
    Thanks in advance.
    Pedro Sena

    Pedro,
    The Data Server config for InternalDateFormat should be:  MM/dd/yyyy HH:mm:ss
    This is because it is used in conjunction with the DatePrefix and DateSuffix whenever you use the DateColumn or  the [SD] and [ED] tokens in a query template.
    If you are inserting a date field with an arbitrary parameter (not a date token like above) then you need to use the TO_DATE wrapper pieces around your date field string.
    The DateFormat in the query template controls the format of the StartDate and EndDate buttons in the applet toolbar if using an iChart/iSPCChart/iGrid and a time sensitive query, but when you build the string for an insert parameter you must manage the whole format yourself.
    If you really just want datenow and the xMII server time is sufficient for your insert query then you can leverage the Data Server config settings like: INSERT INTO TABLE VALUES([ED)
    This way the default query template time settings will use 'now' for the end date of the query and when the string is sent to Oracle it will actually look like:
    INSERT INTO TABLE VALUES(TO_DATE('10/19/2007 08:41:00', 'MM/DD/YYYY HH24:MI:SS'))
    Regards,
    Jeremy

  • 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

  • How CallableStatement in JSP use setDate() method to insert the date value into DB?

    Dear all,
    I met a strange error message when i insert a date value into DB via JSP call PL/SQL procedures.
    The error seems caused by the setDate(index, date) method with CallableStatement.
    The message is: Can not find the setDate(int, java.util.Date) method in the CallableStatement interfaces.
    Any ideas?
    Thanks advanced.

    Thank you!:)
    I solved it using this:
    String name="david";
                stmt = con1.createStatement();
                String prikaz1 = "INSERT INTO table (id,age,surname,name) IN 'C:\\Users\\David\\Desktop\\db.mdb' SELECT id,age,surname,' " + name + " ' FROM table2";
                stmt.executeUpdate(prikaz1);

  • Interactive Report - Chart axis value wrong data

    Hi,
    we created an interactive report based on demo_orders table.
    The interactive chart is displaying wrong data on the value axis (4,00000 instead of 4,000.00)!
    Values in the table are ok, even the value displayed when user clicks on specific data point is correct.
    Did somebody had similar problems?
    Application Express 3.2.0.00.27
    AnyChart #5.1.3
    Thanks.
    Regards,
    Kristjan

    Hi Kristjan,
    I'm able to reproduce the issue you report, using an Interactive Report in APEX 3.2.1 and 4.0, where the Application Language is a non-English option. So for example, if my chart label in English is *10,000.00* and when I switch the Application Primary Language to German, then the displayed values should be *10.000,00* however it is incorrectly appearing as *10,000*. When running in some non-English languages, the NLS decimal separator used is a comma ',', but this isn't been correctly applied to the Interactive Report chart. The problem is arising from the fact that the decimal separator setting in the chart XML is not being escaped correctly, and is therefore being ignored. I've logged bug 10154666 to track this issue, and a fix for this will be available in our next release. Thanks for bringing this to our attention. In the meantime, and to ensure the values on your chart are accurately displayed, it might be best to create a separate chart region on the page in question, rather than using the Interactive report chart.
    Regards,
    Hilary

  • Report returns wrong data when run on server

    Hi,
    I'm runing CRS XI R2 on Windows Server 2003 SP2.  When I refresh a report in the Crystal Reports XI Designer, I'm getting correct data.  But when I schedule the report to run on the server it returns wrong data.  The data is different from what I see when I refresh it from the designer.  In the report I have running totals set up to count customers that meet a certain criteria.  The report is very large.  It take almost 2 hours to refresh.
    I was wondering what is causing the difference in running total data between refreshing it on the designer and running it on the server.  Is it returning wrong data b/c of it not reading all the records?  Should I be making any changes to the server settings?  I saw that under pageserver, there are options for  setting the 'Minutes Before an Idle Report Job is Closed' and 'Database Records To Read When Previewing Or Refreshing a Report".  Do either of those have anything to do with the report returning incorrect data when being scheduled to run on the server?
    Thanks,
    Kim

    Hi Xuandao,
    You would need to Use Cell Binding and Trigger concept to accomplish this.
    Its simple, however, you would have to work on a trial and error basis to understand this concept as implementing the same is subject to your dashboard and WEBI Design.
    Open you LiveOffice.
    Insert your WEBI, Now, go to Object Properties of your WEBI, select the second tab that says Prompt, Here, it lists the prompts that you have for your WEBI. This would also enlist your BEx variables as well. Select this BEx variable and click on the button that says Prompt at the bottom of this window. Here, select choose Excel Data Range and click on the cell select button on the right (small button that lets you choose what cell you want to bind this prompt to), Now select a free cell that would not be even populated later on when you run the dashboard say A1 (remember the value that you select). Click on OK and again OK. The WEBI Refreshes and you can see all the prompt values at the cell A1. These are all the possible values stored for your BEx prompt variables (these values are fetched from BW system dynamically).
    Now, save this LiveOffice, Go to you dashboard. Connect your dashboard to your Live office. Go to Data-> connections-> Now, select the WEBI and in the right hand pane  go to Usage tab, here, Click on Trigger cell button on the right hand side and select A1 in you LiveOffice.
    It should work fine.
    Let me know.
    Rgds,
    Sreekul Nair

Maybe you are looking for

  • Unable to display a variable value in xml through xsl using coldfusion

    Hi ColdFusion Heroes , Is their any one to help me in this issue . I am new to cold fusion , XML and XSL . Detail Explaination : develoment_files.cfm is a .cfm page , which includes an xml page . development_files_dropdown.xsl is a xsl page . develom

  • Setting Up a Shared Address Book

    Hello, and thank you for taking a look at my question. I concur with the many people on this forum who are amazed how frustratingly difficult it is to setup a shared Address Book. I have a small office network of 4 users (all running the latest Snow

  • Interactive movie controls

    Hi, Sorry if this a silly question or not appropriate for Premiere. I am creating a presentation for my company, a corporate looking one. I built one in Flash, which was fine, but a bit fidly, as the presentation was very long (about ten minutes) and

  • Play's Fine on Mine But Not on Thier's

    Okay, this is my situation.  I have a presentation that I have imported from PowerPoint with audio that I have on the Captivate 4 timeline.  I have gone into and edited the entry and exit anmimations in the PowerPoint presentation from the Captivate

  • IOS 8 problem in Spotlight

    In my ipad mini running newest ios 8, When iam slide down in homescreen, and then the display turn into grayscale. Why?