Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date or Varchar data field for timestamp 1

Status
Not open for further replies.

rudejohn

IS-IT--Management
Jul 11, 2003
130
0
0
US
Okay here's my problem:

I am writing an application which will log metrics data for a transaction into an ORACLE database. The key data piece we need is a timestamp... for start and stop time. The events, though, sometimes take as little as 10 milliseconds, and Oracle only stores timestamps down to the SECOND. So the way I see it, I have two options:

(1) Use the Date field in the database. Store the start and stop time that way, and ALSO store an integer which is calculated using timeInMillis(). Then the start/stop date field isn't USED in calculating the elapsed time.
(2) Create the timestamp in Java, which would include milliseconds, and insert it into a VARCHAR field. Then, when we pull it out, use Java to add/subtract, etc.

Which of these, in your opinions, is more efficient? Our development team is split...

************
RudeJohn
************
 
2
java will use the System.currentTimeMillis() function.Date calculation won't be difficult.
Assuming that you store your data as string,
data convertion would look like this
java.sql.Date myDate=new java.sql.Date(Long.parseLong(yourdatetimestampasstring);
No need to keep 2 data where one will do.

Salih Sipahi
Software Engineer.
City of Istanbul Turkey
s.sipahi@sahinlerholding.com.tr
turkey_clr.gif
 
Thank you, your response is quite helpful.

RJ

************
RudeJohn
************
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top