Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Database Server Software > Oracle > Date format

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-06-03, 16:34
svrider svrider is offline
Registered User
 
Join Date: Jul 2002
Posts: 36
Date format

Hello all,

I'd like to extract the system date (or any date) with a format including the miliseconds (I don't know if this is a good english word... I'm looking for the thousandth of seconds...)

If I do :

select to_char(sysdate, 'YYYY-MM-DD HH24:MIS') from dual;

I have the seconds... what is the correct format string to add the thousandth ?

I need that to make a very very basic random so I figured why not use a fraction of a second...

If you have a better idea for a random number between... say 1 to 20, I'm all ears !

Thanks a million !

SvRider.
Reply With Quote
  #2 (permalink)  
Old 02-07-03, 04:59
NoviceNo1 NoviceNo1 is offline
Registered User
 
Join Date: Jan 2003
Location: Woking
Posts: 107
Re: Date format

Quote:
Originally posted by svrider
Hello all,

I'd like to extract the system date (or any date) with a format including the miliseconds (I don't know if this is a good english word... I'm looking for the thousandth of seconds...)

If I do :

select to_char(sysdate, 'YYYY-MM-DD HH24:MIS') from dual;

I have the seconds... what is the correct format string to add the thousandth ?

I need that to make a very very basic random so I figured why not use a fraction of a second...

If you have a better idea for a random number between... say 1 to 20, I'm all ears !

Thanks a million !

SvRider.


Hi,
i dont know how to format a 1000th of a second, but if you
are trying to generate a random number, along with the
date, try this SQL

SELECT TO_CHAR(SYSDATE, 'YYYY-MM-DD HH24:MIS')
||':'||SUBSTR(ABS(DBMS_RANDOM.RANDOM),1,3)
FROM DUAL

Also to generate random numbers, you can use DBMS_RANDOM.
__________________
nn
Reply With Quote
  #3 (permalink)  
Old 02-07-03, 06:38
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 4,874
Re: Date format

Quote:
Originally posted by svrider
If you have a better idea for a random number between... say 1 to 20, I'm all ears !
SvRider.

That's easy:

SQL> select dbms_random.value(1,20) from dual;

DBMS_RANDOM.VALUE(1,20)
-----------------------
16.4037983

You could ROUND that to get an integer between 1 and 20.
__________________
Tony Andrews
http://tonyandrews.blogspot.com
Reply With Quote
  #4 (permalink)  
Old 02-07-03, 10:02
svrider svrider is offline
Registered User
 
Join Date: Jul 2002
Posts: 36
Thanks a lot guys ! I saw the dbms_random int he documentation, but didn't know I could use it in a SELECT statement.

This will do just great !

SvRider.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On