Re: Date calculations on the command line (was: Us
Posted in 2011
On Thu, Mar 17, 2011 at 04:58, Marcus Haarmann <marcus.haarmann@midoco.de>wrote: > date -d "1 day ago" +%Y%m%d > > works min. for linux. Did not try in other OS. > It will work where you get the GNU implementation of date; it won't work on other versions of Unix (Solaris, AIX, HP-UX, MacOS X, *BSD) where you don't. -----Original Message----- > From: Long Nguyen [mailto:longhuynguyen51@yahoo.com.au] > > By the way another request: How to calculate a date in a Unix script, eg > today - n days? > sqlcmd -d stores -e "select today - ${n:-0} from dual" I create a table 'dual' in my databases. IDS has a sysdual table somewhere (sysmaster:sysdual) but its name isn't 'dual' so it isn't as convenient as 'dual' is. Yes, I could do "create synonym dual for sysmaster:sysdual" in my database, but it still defeats the usability objective - to make the Oracle-compatible DUAL available in a regular database. It would also be nice if IDS allowed the FROM clause to be omitted - effectively inferring DUAL; then you'd write "select today - ${n:-0}" as the SELECT statement. AFAIK, DB-Access doesn't make it as convenient to process SQL like that; it generates extraneous output and doesn't accept commands in a string on the command line. -- Jonathan Leffler <jonathan.leffler@gmail.com> #include <disclaimer.h> Guardian of DBD::Informix - v2008.0513 - http://dbi.perl.org "Blessed are we who can laugh at ourselves, for we shall never cease to be amused." --001517473430240a6d049eae3853