× 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.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 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.