Unix Technical Forum

getting milliseconds from a DATE

This is a discussion on getting milliseconds from a DATE within the Oracle Miscellaneous forums, part of the Oracle Database category; --> Hello, I'm using Oracle 9i on Solaris. How do I take a column of a DATE type and convert ...


Go Back   Unix Technical Forum > Database Server Software > Oracle Database > Oracle Miscellaneous

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-08-2008, 10:25 AM
laredotornado@zipmail.com
 
Posts: n/a
Default getting milliseconds from a DATE

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-08-2008, 10:25 AM
ianal Vista
 
Posts: n/a
Default Re: getting milliseconds from a DATE

laredotornado@zipmail.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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-08-2008, 10:25 AM
Robert Klemme
 
Posts: n/a
Default Re: getting milliseconds from a DATE

ianal Vista wrote:
> laredotornado@zipmail.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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-08-2008, 10:25 AM
Brian Peasland
 
Posts: n/a
Default Re: getting milliseconds from a DATE

Robert Klemme wrote:
> ianal Vista wrote:
>> laredotornado@zipmail.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@nospam.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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-08-2008, 10:25 AM
Laurenz Albe
 
Posts: n/a
Default Re: getting milliseconds from a DATE

Brian Peasland <oracle_dba@nospam.peasland.net> wrote:
> Robert Klemme wrote:
>> ianal Vista wrote:
>>> laredotornado@zipmail.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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 04-08-2008, 10:25 AM
Brian Peasland
 
Posts: n/a
Default Re: getting milliseconds from a DATE

> 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@nospam.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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 04-08-2008, 10:25 AM
Robert Klemme
 
Posts: n/a
Default Re: getting milliseconds from a DATE

Brian Peasland wrote:
>> 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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 04-08-2008, 10:25 AM
marcus.rangel@gmail.com
 
Posts: n/a
Default Re: getting milliseconds from a DATE

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)

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
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
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 12:22 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com