Results 1 to 4 of 4

Thread: Date format

  1. #1
    Join Date
    Jul 2002
    Posts
    42

    Unanswered: 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.

  2. #2
    Join Date
    Jan 2003
    Location
    Woking
    Posts
    107

    Re: Date format

    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

  3. #3
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1

    Re: Date format

    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.

  4. #4
    Join Date
    Jul 2002
    Posts
    42
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •