Ask the Expert

LTRIM function

I am having trouble with zero suppression of the time function. LTRIM(TO_CHAR(S_DATE, 'HH:MI AM'). I'm on 9i. The results looks like this: 08:00 AM.

    Requires Free Membership to View

The LTRIM function will remove any set of characters from the left side of the string. Since you did not tell it which set of characters to trim off the string, the LTRIM function will remove any blanks from the left side of the string. The RTRIM function works similarly, but from the right side of the string. You are converting a date field to a string and then LTRIM will remove any leading blanks. Unfortunately, with your function, there are no leading blanks. If you wish to remove the leading zero, then you'll need to let LTRIM know this as follows:

LTRIM(TO_CHAR(S_DATE, 'HH:MI AM'),'0')

The second parameter to the LTRIM function tells it to remove the leading zero.

This was first published in October 2003

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: