Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format to use for no leading zeros in dates

Status
Not open for further replies.

western93

Technical User
Jan 14, 2005
4
US
Hi,


I am trying to insert new dates into table, but having problems getting the format correct. Currently, I am finding the Max date in the table and adding 1 to the variable inside of a for loop. The dates are incrementing as desired but the format is 02/09/2006. The format that I need is 2/9/2006 (no leading zeros).


Thanks,
Penny
 
Penny said:
I am trying to insert new dates into table, but having problems getting the format correct.
Penny, if you are truly inserting dates (versus character) into a table, you have absolutely no control of the format of a date in a table...all Oracle dates have the same internal storage format. You have control over the display format only of a date coming out of a table.


If you are wanting to suppress leading zeros for any date component (i.e., "DD" or "MM" or "YY"), then you can us the "fm" mask in your "to_char" function as follows:
Code:
select to_char(sysdate-13,'mm/dd/yyyy')x from dual;

X
----------
02/09/2006

select to_char(sysdate-13,'[b]fm[/b]mm/dd/yyyy')x from dual;

X
----------
2/9/2006
(I believe that the "fm" stands for "freakin' magic" [wink].)

Does this answer your question?

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[ Providing low-cost remote Database Admin services]
Click here to join Utah Oracle Users Group on Tek-Tips if you use Oracle in Utah USA.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top