This content has been marked as final. Show 5 replies
SELECT col1,col2 FROM bill WHERE
trunc (TO_DATE(time_stamp, 'yyyy/mm/dd HH:MI:SS AM') = trunc (TO_DATE('2012/01','yyyy/mm');
This only returns data for first day of the month and need data for a month.
I answered that question in the other forum.
Well a TRUNC without a format string only gives you one day. If you want to trunc to the month you need a 'MM' format string.
And if this is true ' sample data is 20120204103342 and 20120204152550 '
SELECT sysdate, trunc(sysdate), trunc(sysdate, 'MM'), trunc(TO_DATE('2012/01','yyyy/mm')) td from dual SYSDATE,TRUNC(SYSDATE),TRUNC(SYSDATE,'MM'),TD 10/30/2012 6:48:53 PM,10/30/2012,10/1/2012,1/1/2012
Then this won't work because the format string doesn't match your sample data
And if that did work the TRUNC still only gives you the day
TO_DATE(time_stamp, 'yyyy/mm/dd HH:MI:SS AM')
SELECT trunc (TO_DATE('20120204103342', 'yyyymmddHHMISS')) from dual TRUNC(TO_DATE('20120204103342','YYYYMMDDHHMISS')) 2/4/2012