![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| compare files in the system with last modified date | bsandeep_80 | Linux | 6 | 01-14-2008 08:56 PM |
| How can i get the yesterday's date in YYYYMMDD format | prasadsr | HP-UX | 4 | 01-19-2007 05:52 AM |
| get yesterday's date? | fedora | Shell Programming and Scripting | 1 | 12-08-2006 11:28 AM |
| Yesterday's date function | ssmiths001 | UNIX for Dummies Questions & Answers | 4 | 01-11-2005 06:06 AM |
| Yesterday's date | ssmiths001 | UNIX for Dummies Questions & Answers | 2 | 11-22-2004 05:46 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
Compare date from db2 table to yesterday's Unix system date
I am currently running the following Korn shell script which works fine:
#!/usr/bin/ksh count=`db2 -x "select count(*) from schema.tablename"` echo "count" I would like to add a "where" clause to the 2nd line that would allow me to get a record count of all the records from schema.tablename where PROCESS_DT(a datetime variable in tablename which is formatted as DATE9.) is equal to the today's unix system date - 1. I'm not sure of the proper syntax. Please help. count=`db2 -x "select count(*) from schema.tablename where PROCESS_DT=UNIX system date-1"` |
| Forum Sponsor | ||
|
|
|
|||
|
|||
|
I now know how to find yesterdays date, however, I get an error message stating that the operands (PROCESS_DT and DATE_STAMP) are not compatible. PROCESS_DT is a DB2 date time variable with a DATE9 format. How can I declare DATE_STAMP to be a date time variable?
#!/usr/bin/ksh DATE_STAMP=`TZ=CST+24 date +%y%m%d` count=`db2 -x "select count(*) from schema.tablename where PROCESS_DT="$DATE_STAMP""` echo "$count" |
|
|||
|
I'm not familiar with db2 but you should do something like:
Code:
DATE_STAMP=`TZ=CST+24 date +%Y-%m-%d`
count=`db2 -x "select count(*) from schema.tablename where PROCESS_DT=DATE("$DATE_STAMP")`
Regards |