dbTalk Databases Forums  

getting milliseconds from a DATE

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss getting milliseconds from a DATE in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
AT
 
Posts: n/a

Default getting milliseconds from a DATE - 05-08-2006 , 08:13 AM






Hello,

I'm using Oracle 9i on Solaris. How do I take a column of a DATE type
and convert it to milliseconds that have elapsed since Jan. 1, 1970, 12
AM?

Thanks for any help, - Dave


Reply With Quote
  #2  
Old   
ianal Vista
 
Posts: n/a

Default Re: getting milliseconds from a DATE - 05-08-2006 , 09:00 AM






laredotornado (AT) zipmail (DOT) com wrote in news:1147093983.362115.82810
@y43g2000cwc.googlegroups.com:

Quote:
Hello,

I'm using Oracle 9i on Solaris. How do I take a column of a DATE type
and convert it to milliseconds that have elapsed since Jan. 1, 1970, 12
AM?

Thanks for any help, - Dave


You do NOT get millisecond from DATE; must use TIMESTAMP


Reply With Quote
  #3  
Old   
Robert Klemme
 
Posts: n/a

Default Re: getting milliseconds from a DATE - 05-08-2006 , 10:31 AM



ianal Vista wrote:
Quote:
laredotornado (AT) zipmail (DOT) com wrote in news:1147093983.362115.82810
@y43g2000cwc.googlegroups.com:

Hello,

I'm using Oracle 9i on Solaris. How do I take a column of a DATE type
and convert it to milliseconds that have elapsed since Jan. 1, 1970, 12
AM?

Thanks for any help, - Dave



You do NOT get millisecond from DATE; must use TIMESTAMP
Hey, you could have been more helpful. Why didn't you suggest to
convert the DATE to TIMESTAMP and then extract ms?

SCNR

robert


Reply With Quote
  #4  
Old   
Brian Peasland
 
Posts: n/a

Default Re: getting milliseconds from a DATE - 05-08-2006 , 11:05 AM



Robert Klemme wrote:
Quote:
ianal Vista wrote:
laredotornado (AT) zipmail (DOT) com wrote in news:1147093983.362115.82810
@y43g2000cwc.googlegroups.com:

Hello,

I'm using Oracle 9i on Solaris. How do I take a column of a DATE type
and convert it to milliseconds that have elapsed since Jan. 1, 1970, 12
AM?

Thanks for any help, - Dave



You do NOT get millisecond from DATE; must use TIMESTAMP

Hey, you could have been more helpful. Why didn't you suggest to
convert the DATE to TIMESTAMP and then extract ms?

SCNR

robert
Converting a DATE to a TIMESTAMP will not yield any millisecond values
other than 0. You cannot obtain more precision out of a value in one
datatype by converting it to a different datatype. For instance, you
cannot convert an integer value 'X' to a floating point number and get
more than 'X.0' out of it.

HTH,
Brian


--
================================================== =================

Brian Peasland
oracle_dba (AT) nospam (DOT) peasland.net
http://www.peasland.net

Remove the "nospam." from the email address to email me.


"I can give it to you cheap, quick, and good.
Now pick two out of the three" - Unknown


Reply With Quote
  #5  
Old   
Laurenz Albe
 
Posts: n/a

Default Re: getting milliseconds from a DATE - 05-09-2006 , 02:36 AM



Brian Peasland <oracle_dba (AT) nospam (DOT) peasland.net> wrote:
Quote:
Robert Klemme wrote:
ianal Vista wrote:
laredotornado (AT) zipmail (DOT) com wrote in news:1147093983.362115.82810
@y43g2000cwc.googlegroups.com:

Hello,

I'm using Oracle 9i on Solaris. How do I take a column of a DATE type
and convert it to milliseconds that have elapsed since Jan. 1, 1970, 12
AM?

Thanks for any help, - Dave



You do NOT get millisecond from DATE; must use TIMESTAMP

Hey, you could have been more helpful. Why didn't you suggest to
convert the DATE to TIMESTAMP and then extract ms?

SCNR

robert

Converting a DATE to a TIMESTAMP will not yield any millisecond values
other than 0. You cannot obtain more precision out of a value in one
datatype by converting it to a different datatype. For instance, you
cannot convert an integer value 'X' to a floating point number and get
more than 'X.0' out of it.
Let me propose 'the punchline conjecture':

No matter how simple a joke is, there will always be someone who doesn't
get it, provided the audience is big enough.

Yours,
Laurenz Albe


Reply With Quote
  #6  
Old   
Brian Peasland
 
Posts: n/a

Default Re: getting milliseconds from a DATE - 05-09-2006 , 09:57 AM



Quote:
Let me propose 'the punchline conjecture':

No matter how simple a joke is, there will always be someone who doesn't
get it, provided the audience is big enough.
If it was a joke, then it should have included an emoticon of some
sort...i.e. or

Since there are no voice inflections or facial indicators to form a
basis of the tone, emoticons are all we have in this forum.

Cheers!
Brian




--
================================================== =================

Brian Peasland
oracle_dba (AT) nospam (DOT) peasland.net
http://www.peasland.net

Remove the "nospam." from the email address to email me.


"I can give it to you cheap, quick, and good.
Now pick two out of the three" - Unknown


Reply With Quote
  #7  
Old   
Robert Klemme
 
Posts: n/a

Default Re: getting milliseconds from a DATE - 05-09-2006 , 10:38 AM



Brian Peasland wrote:
Quote:
Let me propose 'the punchline conjecture':

No matter how simple a joke is, there will always be someone who doesn't
get it, provided the audience is big enough.

If it was a joke, then it should have included an emoticon of some
sort...i.e. or

Since there are no voice inflections or facial indicators to form a
basis of the tone, emoticons are all we have in this forum.
If you look closely at my post you'll discover the four letters
"SCNR"... I didn't want to make it too easy to spot. Also the use of
common sense is explicitly *not* prohibited in this forum - or was it
"is not explicitly prohibited"?



robert


Reply With Quote
  #8  
Old   
marcus.rangel (AT) gmail (DOT) com
 
Posts: n/a

Default Re: getting milliseconds from a DATE - 05-09-2006 , 11:46 AM



But he probably does not need to be so precise, right ? He could create
a 'timestamp' column to replace the 'date' one, and accept to lose the
last second for the previous data, calculating the number through
something like this:

SQL> select time_diff('01-JAN-70',sysdate) * 1000 from dual;

TIME_DIFF('01-JAN-70',SYSDATE)
------------------------------
1147182144000

(code for time_diff : http://www.psoug.org/reference/date_func.html)


Reply With Quote
Reply




Thread Tools
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 On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.