|
On 31-Aug-2011 05:18 , Joe Pluta wrote:
On 8/31/2011 7:06 AM, Schutte, Michael D wrote:I think little thought or concern was given for enabling "legacy" use
Instead of using iDate, use Date.Ugh. You'd think in 2011 the SQL standard would have some decent
Where
Date(digits(post_date) concat '000000') = current_date - 1 days
date formatting, rather than having to remember this (or the '-'
replace trick).
of numeric data to represent dates, by those behind the standards.
Seems the assumption had been that everyone started with\from SQL DDL so
nobody would have a reason to cast from some of the many possible
date-like numeric values or even strings.
Given how little the DB2 for i SQL strays from the standards, are
both of TIMESTAMP_FORMAT and VARCHAR_FORMAT included? The following two
expressions are a date value derived from a timestamp expression. The
intent of the latter may be more conspicuous, but the latter is neither
as succinct nor available for use in a derived index:
DATE(DIGITS(yyyymmdd) concat '000000')
DATE(TIMESTAMP_FORMAT(DIGITS(yyyymmdd), 'YYYYMMDD') )
The "trick" used to replace the '-' in an ISO date string [e.g.
replace(char(date('2011-03-31'),iso),'-','')] is AFaIK similarly
available [untested] with a more conspicuous intent via:
VARCHAR_FORMAT(TIMESTAMP_ISO('2011-03-31'),'YYYYMMDD')
VARCHAR_FORMAT(TIMESTAMP_ISO(current_date-1 day),'YYYYMMDD')
The use of TIMESTAMP_ISO over TIMESTAMP in the above is to allow
omission of any time-related values in the expressions.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.