×
The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.
On 31-Aug-2011 05:18 , Joe Pluta wrote:
On 8/31/2011 7:06 AM, Schutte, Michael D wrote:
Instead of using iDate, use Date.
Where
Date(digits(post_date) concat '000000') = current_date - 1 days
Ugh. You'd think in 2011 the SQL standard would have some decent
date formatting, rather than having to remember this (or the '-'
replace trick).
I think little thought or concern was given for enabling "legacy" use
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.
Regards, Chuck
As an Amazon Associate we earn from qualifying purchases.