permaculture playing cards*
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "adding time stamp to date column" Watch "adding time stamp to date column" New topic
Author

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: 3704
    
    5

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
Marshal

Joined: May 26, 2003
Posts: 30353
    
150

Eshwar,
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: 3704
    
    5

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: http://aspose.com/file-tools
 
subject: adding time stamp to date column