Date Question [message #23101] |
Mon, 18 November 2002 10:52 |
Rizwan Qazi
Messages: 135 Registered: August 2002
|
Senior Member |
|
|
I have a field called book_date. I want to write a query where I want to replace the output by the first day of the corresponding month. The query I am using currently is
select ADD_MONTHS(LAST_DAY(BOOK_DT),-1)+1 from TRANSACTION_QUEUE
to Return this output
I tried to use
select TO_DATE(TO_CHAR(BOOK_DT),'YYYYMM') from TRANSACTION_QUEUE
but I get the error
ERROR at line 1:
ORA-01830: date format picture ends before converting entire input string
What am I doing wrong? Which query is more efficient?
Thanks,
Rizwan
|
|
|
|
Re: Date Question [message #23109 is a reply to message #23101] |
Mon, 18 November 2002 15:13 |
Amit Chauhan
Messages: 74 Registered: July 1999
|
Member |
|
|
Hi,
Just to elaborate on Todd's reply. The query you are looking for may look like this :
select to_date ('01'||to_char(book_dt, 'mmyyyy'), 'ddmmyyyy')
from transaction_queue
Hope that helps
Thanks
Amit
|
|
|
|