The date format in which you see a "real" date without converting into a
charcter representation depends on the date format used in the SQL
environment where the query is run.
When working with STRSQL the date format is set with Funktion Key F13 -->
Option 1 --> Options DATFMT and DATSEP
When working with embedded SQL just set the date format in the SET OPTION
statement, but make sure that no date outside the valid range is moved into
the appropriate host variables.
Mit freundlichen Grüßen / Best regards
Birgitta Hauser
"Shoot for the moon, even if you miss, you'll land among the stars." (Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training them
and keeping them!"
-----Ursprüngliche Nachricht-----
Von: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] Im Auftrag von Robert Clay
Gesendet: Thursday, 05.9 2013 18:07
An: midrange-l@xxxxxxxxxxxx
Betreff: Formatting a DATE differently using SQL
Before I forget, this is for a v6.1.0 system.
I know that I've seen this addressed numerous times before but my friend
Google just cannot seem to locate it based on the input that I've given.
Using SQL, I want to display a value formatted as MM/DD/YY (with the slash
separators) from a date data type column as succinctly as possible. (This
will be the MIN date in the file based on other criteria in the WHERE
clause, but that's superfluous).
The best I can come up with is:
SUBSTR(CHAR(MIN(dayid)),6,2) CONCAT '/' CONCAT
SUBSTR(CHAR(MIN(dayid)),9,2) CONCAT '/' CONCAT
SUBSTR(CHAR(MIN(dayid)),3,2) AS StartDate
Ugly, but it works. There has to be an easier way. I hope someone has a
better idea.
Thanks in advance,
Robert
--
"Contrariwise, if it was so, it might be; and if it were so, it would be;
but as it isn't, it ain't. That's logic."--Tweedledee
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe, unsubscribe,
or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a
moment to review the archives at
http://archive.midrange.com/midrange-l.
As an Amazon Associate we earn from qualifying purchases.