Ask the Expert

Displaying time, including milliseconds

I am using the Oracle9i database. In one of my applications, I need to display time, including milliseconds. The current format is "Hour:Minutes;Seconds". The required format is "Hours:Minutes:Seconds:Milliseconds". Can you help in this issue?

    Requires Free Membership to View

A date datatype does not contain milliseconds. A timestamp datatype stores fractional seconds. If you are using dates you'll have to convert them to timestamp datatypes.

However, if you are using timestamps, try this:

create table ts_info ( ts1 timestamp )

insert into ts_info (ts1)
  values (systimestamp)

select ts1, 
       to_char(ts1, 'YYYY-MM-DD HH24:MI:SS.FF') 
from ts_info

This was first published in June 2005

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: