If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > DB2 Date vs Unix System Date

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-24-08, 12:05
sasaliasim sasaliasim is offline
Registered User
 
Join Date: Apr 2008
Posts: 2
Question DB2 Date vs Unix System Date

In the following Korn shell script, I am attempting to get a count all of the rows from a db2 table in which the PROCESS_DT is equal to yesterday's UNIX system date. The script runs without error, but returns a count of 0 when I am 100% certain that there are over 3 millions records with a PROCESS_DT equal to yesterday's date. Does any one have any suggestions?

#!/usr/bin/ksh
DATE_STAMP=`TZ=CST+24 date +%Y-%m-%d`
RecCount='db2 -x "select count(*) from schema.tablename where PROCESS_DT=DATE("$DATE_STAMP")`
echo "$RecCount"
echo "$DATE_STAMP"
Reply With Quote
  #2 (permalink)  
Old 04-24-08, 12:37
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
You should verify that the string in "DATE_STAMP" is actually a valid string representation for a date value. Next, you have to have single-quotes in the SQL statement to get the string as string to DB2, i.e. something like:
Code:
db2 -x "select count(*) from schema.tablename where PROCESS_DT=DATE('$DATE_STAMP')
Also, you have a single-quote in next to "RecCount=" but a back-tick at the end. This can't work anyway.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On