Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7659807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:22:54+00:00 2026-05-31T13:22:54+00:00

Actually I am just trying to insert string something like this 30/01/2012 into a

  • 0

Actually I am just trying to insert string something like this 30/01/2012 into a table where that particular table column is of type varchar. After insertion this value is changed into 0.008946322067594433. What may be the reason for this behaviour? Please let me know what I am doing wrong here. I am very poor in database/SQL concepts.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T13:22:55+00:00Added an answer on May 31, 2026 at 1:22 pm

    I suspect your SQL looks something like:

    INSERT INTO MYTABLE (X) VALUES (30/01/2012)
    

    in which case it’s not treating it as a string, but an expression to evaluate – which is then being converted into a string. If this is the case, it sounds like you’re building up your SQL string including the value, e.g.

    String sql = "INSERT INTO ... VALUES (" + value + ")";
    

    Don’t do that. Use a PreparedStatement and set parameter values instead. Not only will it avoid this problem, it will also avoid SQL injection attacks, conversion problems with dates and times, etc.

    (Speaking of which, assuming this value is meant to be a date, why are you storing it in a varchar column? If you possibly can, make your columns represent the data you wish to store more naturally…)

    EDIT: I’ve just downloaded and installed MySQL to test this… and indeed in a table with a single column (Name) this SQL statement does the wrong thing (in MySQL Workbench):

    INSERT INTO `test`.`sandbox` (`Name`) VALUES (30/01/2012);
    

    … but this does the right thing:

    INSERT INTO `test`.`sandbox` (`Name`) VALUES ('30/01/2012');
    

    But you should still use a prepared statement with parameters, of course.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Actually i am just trying to develop Box like app for iphone for practice,
Premise This problem has a known solution (shown below actually), I'm just wondering if
I've got a typical problem when trying to insert a date into MySQL. The
I'm just trying to make a simple function that will return all the data
I have been trying to use Hibernate for a while. I like hibernate that
I'm trying to insert a bunch of rows into an empty UITableView in one
Just trying to get my irb sessions to actually list the current line of
I've been running my head into a wall trying to figure this out. Take
I am just trying to use this as a very simple register system and
I am trying to parse an RSS feed with feedparser and insert it into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.