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 > Time diff - Epoch time (first shot)

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-28-10, 15:35
goldfishhh goldfishhh is offline
Registered User
 
Join Date: Nov 2004
Posts: 54
Time diff - Epoch time (first shot)

I'm trying to get an epoch timestamp created for two date/times and the system keeps saying that I have a missplaced ":". I just can't see where I went wrong.

DT_DT is DATETIME format and TM_TXT is VARCHAR(255)

Code:
        ,TIMESTAMPDIFF(2,(TIMESTAMP(1970-01-01,00:00:02.06)          
          TIMESTAMP(  (SUBSTR(CHAR(DT_DT),1,4))        || '-' ||     
                      (SUBSTR(CHAR(DT_DT),6,2))        || '-' ||     
                      (SUBSTR(CHAR(DT_DT),9,2))        || ',' ||     
            "0"                                               ||     
            CHAR(SUBSTR(TM_TXT,LOCATE(':',TM_TXT)-1,1))|| ":" ||     
            CHAR(SUBSTR(TM_TXT,LOCATE(':',TM_TXT)+1,2))|| ":" ||     
            CHAR(SUBSTR(TM_TXT,LOCATE(':',TM_TXT)+4,2))|| '.7'       
                          )                                          
                       )                                             
                                              -- WHACKYTIME,         

---------+---------+---------+---------+---------+---------+---------+--------
DSNT408I SQLCODE = -104, ERROR:  ILLEGAL SYMBOL ":". SOME SYMBOLS THAT MIGHT  
         BE LEGAL ARE: MICROSECONDS MICROSECOND SECONDS SECOND MINUTES MINUTE 
         HOURS                                                                
DSNT418I SQLSTATE   = 42601 SQLSTATE RETURN CODE                              
DSNT415I SQLERRP    = DSNHPARS SQL PROCEDURE DETECTING ERROR                  
DSNT416I SQLERRD    = 3 0  0  -1  1198  502 SQL DIAGNOSTIC INFORMATION        
DSNT416I SQLERRD    = X'00000003'  X'00000000'  X'00000000'  X'FFFFFFFF'      
         X'000004AE'  X'000001F6' SQL DIAGNOSTIC INFORMATION                  
---------+---------+---------+---------+---------+---------+---------+--------
Reply With Quote
  #2 (permalink)  
Old 05-28-10, 15:38
tonkuma tonkuma is offline
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,193
":"s and "0"
Reply With Quote
  #3 (permalink)  
Old 05-28-10, 15:44
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
@goldfishhh: Still haven't figured out string literals, have you?
Reply With Quote
  #4 (permalink)  
Old 05-28-10, 16:26
goldfishhh goldfishhh is offline
Registered User
 
Join Date: Nov 2004
Posts: 54


Yea.
Reply With Quote
  #5 (permalink)  
Old 05-28-10, 23:53
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Well, firstly, forget double quotes. Then read the manual for the TIMESTAMP function to find out what are the data types of its arguments.
Reply With Quote
  #6 (permalink)  
Old 05-29-10, 11:34
DB2Plus DB2Plus is offline
Registered User
 
Join Date: Jul 2009
Posts: 150
TIMESTAMP('1970-01-01-00:00:02.060000(')

Also TIMESTAMPDIFF has format TIMESTAMPDIFF(NNN, Char(m))

Kara
Reply With Quote
  #7 (permalink)  
Old 06-03-10, 06:14
goldfishhh goldfishhh is offline
Registered User
 
Join Date: Nov 2004
Posts: 54
Ahhh, there it goes. I got lost in the sea of quotes, commas and most importantly, the syntax.

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