Home » SQL & PL/SQL » SQL & PL/SQL » date function
icon14.gif  date function [message #619222] Sun, 20 July 2014 08:31 Go to next message
hahaie
Messages: 194
Registered: May 2014
Senior Member
hello,
Is there function for the following operations?
1.for example:
in:01/10/2014 10:25:14 ====>out:01/10/2014 00:00:00
or
in:13/01/2015 13:15:05 ====>out:13/01/2015
--------------------------------------------------------
2.for example:
in:14/12/2014 03:25:12 ====>out:14/12/2014 23:59:59
or
in:28/11/2014 12:10:05 ====>out:28/11/2014 23:59:59
--------------------------------------------------------
The output of the above
Date format should be.
tanks.
Re: date function [message #619224 is a reply to message #619222] Sun, 20 July 2014 08:48 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
Please read and follow the forum guidelines, to enable us to help you:

http://www.orafaq.com/forum/t/88153/0/ and please read http://www.orafaq.com/forum/t/174502/102589/


what is datatype of input argument?
what is datatype of function output?
Re: date function [message #619226 is a reply to message #619224] Sun, 20 July 2014 08:53 Go to previous messageGo to next message
Littlefoot
Messages: 21808
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
SQL> alter session set nls_date_format = 'dd.mm.yyyy hh24:mi:ss';

Session altered.

SQL> select sysdate,
  2         trunc(sysdate) result_1,
  3         trunc(sysdate + 1) - 1 / (24 * 60 * 60) result_2
  4  from dual;

SYSDATE             RESULT_1            RESULT_2
------------------- ------------------- -------------------
20.07.2014 15:52:59 20.07.2014 00:00:00 20.07.2014 23:59:59

SQL>
Re: date function [message #619229 is a reply to message #619222] Sun, 20 July 2014 09:46 Go to previous messageGo to next message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
SQL> select sysdate,
  2         to_char(trunc(sysdate),'DD/MM/YYYY HH24:MI:SS') result_1a,
  3         to_char(sysdate,'DD/MM/YYYY "00:00:00"') result_1b,
  4         to_char(sysdate,'DD/MM/YYYY') result_2,
  5         to_char(trunc(sysdate+1)-1/(24*60*60),'DD/MM/YYYY HH24:MI:SS') result_3a,
  6         to_char(sysdate,'DD/MM/YYYY "23:59:59"') result_3b
  7  from dual
  8  /
SYSDATE             RESULT_1A           RESULT_1B           RESULT_2   RESULT_3A           RESULT_3B
------------------- ------------------- ------------------- ---------- ------------------- -------------------
20/07/2014 16:47:23 20/07/2014 00:00:00 20/07/2014 00:00:00 20/07/2014 20/07/2014 23:59:59 20/07/2014 23:59:59

[Updated on: Sun, 20 July 2014 09:47]

Report message to a moderator

Re: date function [message #619236 is a reply to message #619229] Sun, 20 July 2014 13:59 Go to previous messageGo to next message
Lalit Kumar B
Messages: 3174
Registered: May 2013
Location: World Wide on the Web
Senior Member
@OP, apart from MC's and LF's reply to your question, these links might be useful for you,

http://www.oracle.com/pls/db121/search?word=date+format

Also, nicely summarized by Tim, http://www.oracle-base.com/articles/misc/oracle-dates-timestamps-and-intervals.php

And once you get a good understanding of the format mask, you can further read http://edstevensdba.wordpress.com/2011/04/07/nls_date_format/
Re: date function [message #619366 is a reply to message #619236] Tue, 22 July 2014 00:05 Go to previous messageGo to next message
hahaie
Messages: 194
Registered: May 2014
Senior Member
answer OF Littlefoot is correct
thanks ALL
Re: date function [message #619369 is a reply to message #619366] Tue, 22 July 2014 00:11 Go to previous message
Lalit Kumar B
Messages: 3174
Registered: May 2013
Location: World Wide on the Web
Senior Member
hahaie wrote on Tue, 22 July 2014 10:35
answer OF Littlefoot is correct


Yes of course, and Michel elaborated even more, isn't it? Smile
Previous Topic: Oracle RDBMS equivalent for CONCAT_WS() - create CSV output
Next Topic: use between in case on one fild
Goto Forum:
  


Current Time: Fri Apr 26 12:20:24 CDT 2024