aspose file tools*
The moose likes JDBC and the fly likes adding time stamp to date column Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "adding time stamp to date column" Watch "adding time stamp to date column" New topic

adding time stamp to date column

Eshwar Prasad
Ranch Hand

Joined: Mar 21, 2008
Posts: 202
I have an application developed where the data submits to the below table on clicking submit button.

The table has below columns

create table X(
a number
b varchar
c date

This table is already created in production environment. I now have a requirement to update the records of column C by adding timestamp, so that the precision of any newly inserted records from now would be captured. There are no chances of changing the datatype for the column from date to timestamp.

Please let me know if this could be done.

Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3697

Add a new column then copy the data over. Then remove the original column.

My Blog: Down Home Country Coding with Scott Selikoff
Eshwar Prasad
Ranch Hand

Joined: Mar 21, 2008
Posts: 202
Scott, thanks for your suggestion.

However, as i mentioned, we do not have any permissions to alter the column's datatype or add new column.

Also, I tried to update the timestamp value into the column C which is having date as datatype. I notice that the precision which was availed with timestamp value is lost.

So, is there any other way. Please advice

Jeanne Boyarsky
internet detective

Joined: May 26, 2003
Posts: 29219

Why aren't you allowed to change the table in any way if it doesn't meet the requirement?

[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3697

I'm confused as to what you're asking then. You can't change a field to a timestamp, if your not allowed to change the field to timestamp. That's just not possible.

Granted, date types vary from system to system, so it may be dependent on your system. For example, in MySQL DATE refers to java.sql.Date while DATETIME and TIMESTAMP both refer to java.sql.Timestamp. Interestingly though, they are all subclasses of java.util.Date. In other words, there's a lot of options depending on what your doing.
I agree. Here's the link:
subject: adding time stamp to date column
Similar Threads
problem related to timestamp
MSAccess and JDBC
JDBC - Date
Selecting a DISTINCT date from a Timestamp column
date operations in Hibernate