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 > SQL DateTime Representation Error

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-07-10, 12:40
booman55 booman55 is offline
Registered User
 
Join Date: Oct 2010
Posts: 27
SQL DateTime Representation Error

I need some help from some DB2 gurus...I know a little about ksh scripting and even less about DB2.

I am running a ksh script which will do SQL query to a TSM v6.2 server, which runs on DB2. We used to run this script all the time for previous verisions of TSM which ran a proprietory SQL db. TSM v6 switched to DB2.

I get this error in my output file.

ANR0162W Supplemental database diagnostic information: -1:22007:-180 ([IBM][CLI Driver][DB2/AIX64] SQL0180N The syntax of the string representation of a datetime value is incorrect. SQLSTATE=22007

This is the original code for dateTime:

dateTime () {
timeStamp=$(date +'%Y-%m-%d %H:%M:%S')
theDate=$(date +'%m-%d-%Y')
theTime=$(date +'%H:%M:%S')
return
}

I know this needs to be changed to DB2 format, so I've tried coding this:

dateTime () {
timeStamp=$(date +'%Y-%m-%d-00.00.00.000000')
theDate=$(date +'%m-%d-%Y')
theTime=$(date +'%H:%M:%S')
return
}

and I get the same error. Do I need to update theDate and theTime fields? Am I using the wrong format? Any help will be greatly appreciated.

Thanks!
Reply With Quote
  #2 (permalink)  
Old 10-07-10, 14:09
Lenny77 Lenny77 is offline
Registered User
 
Join Date: Jul 2009
Location: NY
Posts: 886
Why
Quote:
date +'%Y-%m-%d %H:%M:%S'
Maybe: date +'%H:%M:%S + .000000'
Or '%Y-%m-%d %H:%M:%S + .000000' ?

Lenny

Last edited by Lenny77; 10-07-10 at 14:27.
Reply With Quote
  #3 (permalink)  
Old 10-07-10, 14:29
booman55 booman55 is offline
Registered User
 
Join Date: Oct 2010
Posts: 27
Lenny...thanks, but no luck. I get same error.
Reply With Quote
  #4 (permalink)  
Old 10-07-10, 14:42
Lenny77 Lenny77 is offline
Registered User
 
Join Date: Jul 2009
Location: NY
Posts: 886
Use:

Timestamp = Timestamp(date, time)

Lenny
Reply With Quote
  #5 (permalink)  
Old 10-07-10, 15:07
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Quote:
Originally Posted by booman55 View Post
dateTime () {
timeStamp=$(date +'%Y-%m-%d-00.00.00.000000')
theDate=$(date +'%m-%d-%Y')
theTime=$(date +'%H:%M:%S')
return
}
I don't see how that's related to DB2. May be it would make sense for you to print the actual query text before it is executed - it will let you check what may be wrong with it.
Reply With Quote
  #6 (permalink)  
Old 10-07-10, 15:23
booman55 booman55 is offline
Registered User
 
Join Date: Oct 2010
Posts: 27
Quote:
Originally Posted by n_i View Post
I don't see how that's related to DB2. May be it would make sense for you to print the actual query text before it is executed - it will let you check what may be wrong with it.
DB2 comes into play because DB2 has a different date representation for timestamp.

I opened another thread in the SQL forum which was moved here which has the entire script if you want to look at that.

Thanks for the help
Reply With Quote
  #7 (permalink)  
Old 10-08-10, 19:07
booman55 booman55 is offline
Registered User
 
Join Date: Oct 2010
Posts: 27
Any ideas? I'm really in need of some assistance.

Thanks.
Reply With Quote
  #8 (permalink)  
Old 10-09-10, 06:48
Anand.Kaushal Anand.Kaushal is offline
Registered User
 
Join Date: Oct 2010
Posts: 14
the date format is incorrect..

You need to change this:
theDate=$(date +'%m-%d-%Y')
To This:
theDate=$(date +'%Y-%m-%d')
DB2 usually accepts yyyy-mm-dd or dd/mm/yyyy or mm/dd/yyyy - i don't think i've seen the above. Here's a replication of the error:

C:\Users\Andy>db2 select * from sysibm.sysdummy1 where current date = '10-09-2010' with ur
SQL0180N The syntax of the string representation of a datetime value is
incorrect. SQLSTATE=22007


Hope this helps
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