-
trunc and timestamp
Hi,
trunc can only apply on date, but not timestamp.
I need portion of timestamp column, does anyone know how?
For example:
select sysdate, trunc(sysdate, 'month') from dual;
returns:
SYSDATE TRUNC(SYS
--------- ---------
23-AUG-04 01-AUG-04
select current_timestamp from dual;
returns:
CURRENT_TIMESTAMP
---------------------------------------------------------------------------
23-AUG-04 09.56.02.354243 PM -06:00
I need somthing like:
select trunc(current_timestamp, 'month') from dual;
to give
01-AUG-04 instead of error:
*
ERROR at line 1:
ORA-00932: inconsistent datatypes: expected NUMBER got TIMESTAMP
Oracle version 9.2.0.4.
Thanks,
-
Look for To_Char, To_Date functions
funky...
"I Dont Want To Follow A Path, I would Rather Go Where There Is No Path And Leave A Trail."
"Ego is the worst thing many have, try to overcome it & you will be the best, if not good, person on this earth"
-
You might also want to check the EXTRACT() function - it returns the desired field from datetime value.
Jurij Modic
ASCII a stupid question, get a stupid ANSI
24 hours in a day .... 24 beer in a case .... coincidence?
-
In 9i, use the CAST function:
SQL> select trunc(cast (systimestamp as date),'month') from dual;
TRUNC(CAS
---------
01-AUG-04
In 10g you can use trunc with timestamp:
SQL> select trunc(systimestamp,'month') from dual;
TRUNC(SYS
---------
01-AUG-04
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|