Reputation: 182
My question is simple:
I used
TO_CHAR(SYSDATE, 'MM/YYYY');
The problem is the zero, is there any conversion solutions?
Upvotes: 1
Views: 1184
Reputation: 27251
To get rid of leading zeros use FM
format model modifier:
SQL> select TO_CHAR(SYSDATE, 'fmMM/YYYY')
2 from dual
3 ;
TO_CHAR(SYSDATE,'FMMM/YYYY')
----------------------------
8/2013
Upvotes: 3
Reputation: 547
Certainly in PostgreSQL you can add FM before the MM to remove any leading 0's:
Running:
select to_char(now(), 'yyyy/mm/dd');
Produces:
2013/08/07
Whereas running:
select to_char(now(), 'yyyy/FMmm/dd');
Produces:
2013/8/07
And according to this the same should work in oracle.: http://www.techonthenet.com/oracle/functions/to_char.php
So I would try:
TO_CHAR(SYSDATE, 'FMMM/YYYY');
HTH
Upvotes: 2