Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: ??? Number of days betwwen two dates?
This is a multi-part message in MIME format.
--------------60A635CAB3A24F512D4BEFF5
Content-Type: multipart/alternative; boundary="------------77E908B8385B34603C8A13DD"
--------------77E908B8385B34603C8A13DD Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit
Huang, Joseph wrote:
> I need a function, which I can use in other stored procedures, to > return number of days of two given dates. The only similar function I > can found in Oracle manual is MONTHS_BETWEEN(). > Before writing our own function to get correct number of days, I'd> like to know whether this kind of function exists somewhere so I don't > need to redo it. Any suggestions?
The function that Oracle provides for this purpose is "-".
If you subtract two date values from each other you get their difference in days.
Depending on the exact semantics that you want from your DAYS_BETWEEN function you may need to round the dates before you do subtraction.
-- ------------------------------------------------------------------------------- Building the future of business to business electronic commerce... ------------------------------------------------------------------------------- ASM eTrade - Software from the Asian Sources Media Group ------------------------------------------------------------------------------- 24/F Vita Tower, Block B Tel: +852 2814 5678 29 Wong Chuk Hang Road Direct: +852 2814 5671 Aberdeen, Hong Kong Fax: +852 2311 3893 ------------------------------------------------------------------------------- --------------77E908B8385B34603C8A13DD Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bitReceived on Thu Jul 31 1997 - 00:00:00 CDT
<HTML>
<BODY BGCOLOR="#FFFFFF">
Huang, Joseph wrote:
<BLOCKQUOTE TYPE=CITE><FONT FACE="Lucida Console"><FONT COLOR="#000080"><FONT SIZE=-1> I
need a function, which I can use in other stored procedures, to return number of days of two given dates. The only similar function I can found in Oracle manual is MONTHS_BETWEEN().</FONT></FONT></FONT></BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE><FONT FACE="Lucida Console"><FONT COLOR="#000080"><FONT SIZE=-1>Before
writing our own function to get correct number of days, I'd like to know whether this kind of function exists somewhere so I don't need to redo it. Any suggestions?</FONT></FONT></FONT></BLOCKQUOTE> The function that Oracle provides for this purpose is "-".
<P>If you subtract two date values from each other you get their difference
in days.
<P>Depending on the exact semantics that you want from your DAYS_BETWEEN
function you may need to round the dates before you do subtraction.
<BR>
<BR>
<P>--
<BR>-------------------------------------------------------------------------------
<BR>Building the future of business to business electronic commerce...
<BR>-------------------------------------------------------------------------------
<BR>ASM eTrade - Software from the Asian Sources Media Group
<BR>-------------------------------------------------------------------------------
<BR>24/F Vita Tower, Block B
Tel: +852 2814 5678
<BR>29 Wong Chuk Hang Road
Direct: +852 2814 5671
<BR>Aberdeen, Hong Kong
Fax: +852 2311 3893
<BR>-------------------------------------------------------------------------------
<BR>
</BODY>
</HTML>
--------------77E908B8385B34603C8A13DD-- --------------60A635CAB3A24F512D4BEFF5 Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf" Content-Transfer-Encoding: 7bit Content-Description: Card for Michael Friedman Content-Disposition: attachment; filename="vcard.vcf" begin: vcard fn: Michael Friedman n: Friedman;Michael org: Asian Sources Media Group (eTrade) email;internet: mfriedma_at_asiansources.com x-mozilla-cpt: ;0 x-mozilla-html: FALSE end: vcard --------------60A635CAB3A24F512D4BEFF5--