Home » SQL & PL/SQL » SQL & PL/SQL » Pls Explain the Difference (merged)
Pls Explain the Difference (merged) [message #347278] Thu, 11 September 2008 04:21 Go to next message
bernandas
Messages: 16
Registered: June 2007
Location: Chennai
Junior Member
Dear All,

Can anyone pls explain me the different between these queries.

1. SELECT TRUNC(SYSDATE) FROM DUAL;

2. SELECT TRUNC(SYSDATE,'Q') FROM DUAL


Thanks in advance
Pls Explain the Difference [message #347286 is a reply to message #347278] Thu, 11 September 2008 04:32 Go to previous messageGo to next message
bernandas
Messages: 16
Registered: June 2007
Location: Chennai
Junior Member
Dear All,

Can anyone pls explain me the different between these queries.

1. SELECT TRUNC(SYSDATE) FROM DUAL;

2. SELECT TRUNC(SYSDATE,'Q') FROM DUAL


Thanks in advance
Re: Pls Explain the Difference [message #347290 is a reply to message #347286] Thu, 11 September 2008 04:36 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
Trunc truncates a date to a precision specified by the format mask ypu supply in the second parameter.
The defaults is to truncate it to the start of a day.

See here for details of the allowable format models
Re: Pls Explain the Difference [message #347292 is a reply to message #347278] Thu, 11 September 2008 04:37 Go to previous messageGo to next message
harshadsp
Messages: 100
Registered: August 2008
Senior Member

SQL> SELECT TRUNC(SYSDATE) FROM DUAL;

TRUNC(SYS
---------
11-SEP-08

SQL> SELECT TRUNC(SYSDATE,'Q') FROM DUAL;

TRUNC(SYS
---------
01-JUL-08

It truncates to the quarter.
Re: Pls Explain the Difference (merged) [message #347296 is a reply to message #347278] Thu, 11 September 2008 04:43 Go to previous message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
TRUNC (date)

Regards
Michel
Previous Topic: limit of number datatype
Next Topic: Hierarchical Query......
Goto Forum:
  


Current Time: Sun Dec 04 08:40:57 CST 2016

Total time taken to generate the page: 0.04478 seconds