I use to_char(timestamp, 'Mon. DD, YYYY') to format timestamps. Is there an easy way to get it so a period isn't added after the only three-letter month - May? i.e.
Jan. 1, 2003 Feb. 1, 2003 Mar. 1, 2003 Apr. 1, 2003 May 1, 2003 Jun. 1, 2003 ...
take the period out of the to_char(date_field",format")
format portion
Yep, that's what I'm doing now. Was just wondering if anybody had found a way to do both.
could just take the basic date format and write a function in php to do what you want...then just call the function passing the date paramter to that function
Could a case statement be made to handle this, i.e. call the one with a period if the length of the month >3 chars, otherwise call the same function but without a . in it?
That's what I was thinking - something like (pardon any syntax errors):
SELECT CASE WHEN LENGTH(TO_CHAR(ts, 'Month')) <= 3 THEN TO_CHAR(ts, 'Mon DD, YYYY') ELSE TO_CHAR(ts, 'Mon. DD, YYYY') END FROM table1;
I dunno - having the "." isn't that big of a deal 😉.
date("M j, Y"):
for more info http://www.php.net/date
And I would use PHP's date instead of TO_CHAR (and pull stuff out of the database) because...?
sorry didn't realize you were pulling from a database.
You: Look something obvious Me: Where....where I don't see anything.