• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Date conversions from java to SQL

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
from code I need to convert the date and time present in String to a sql date
the code is working fine and values are inserting into database...but when I query in database for the time that is present in date object which was inserted by using below code it is showing only
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Two questions:

1. What is the type of the column in the database where you put that date?

2. Is there a reason why you use a java.sql.Date object and try to put data containing both date and time in it? I would have thought a java.sql.Timestamp object would be better. However it all depends on the type of the database column.
 
ashok movva
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:Two questions:

1. What is the type of the column in the database where you put that date?

2. Is there a reason why you use a java.sql.Date object and try to put data containing both date and time in it? I would have thought a java.sql.Timestamp object would be better. However it all depends on the type of the database column.



1.type of column in database is Date

paul clapham i will try using timestamp, if there is any problem i will get back......thnq
 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the query you use to read that Date value out?
reply
    Bookmark Topic Watch Topic
  • New Topic