MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Cobol SQL and read-in timestamp

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
cappertan
Beginner


Joined: 20 May 2003
Posts: 15
Topics: 10

PostPosted: Wed Sep 08, 2004 3:34 pm    Post subject: Cobol SQL and read-in timestamp Reply with quote

I have code that is giving me a Declare error, however, it does compile.

select *
FROM PAT_ENC
WHERE CAST (UPDATE_DATE AS DATE) >= CONTACT_DATE
AND CAST (:WSZZ-PARM-DATE AS TIMESTAMP)
< UPDATE_DATE

Parm-date comes from a file in which the date is in timestamp format.
Update_date is in timestamp format.

I did try a SUBSTR, as Koluso suggested, but that did not compile.

The runtime message I am getting is: invalid timestamp.

Any suggestions? Question
_________________
Capp
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12369
Topics: 75
Location: San Jose

PostPosted: Wed Sep 08, 2004 5:22 pm    Post subject: Reply with quote

Cappertan,


Quote:

Update_date is in timestamp format.


If your column is of timestamp format, then you can use simply use DATE function to get the date portion from the timestamp. A timestamp is a seven-part value (year, month, day, hour, minute, second, and microsecond) ie.CCYY-MM-DD-HH.MI.SS.NNNNNN ) The length of a TIMESTAMP column is 26 bytes.

So DATE(UPDATE_DATE) would just give the date.

Quote:

Parm-date comes from a file in which the date is in timestamp format.


If you are reading from a file, then why not take the first 10 bytes using reference modification or define the fields in such a way that you get only the date portion.

Code:

01 W-PARM-REC.
   05 WSZZ-PARM-DATE       PIC X(10).
   05 FILLER               PIC X(01).
   05 WSZZ-PARM-TIME       PIC X(08).   
   05 FILLER               PIC X(01).
   05 WSZZ-MC-SEC          PIC X(06).
   05 FILLER               PIC X(64).


In the procedure divison.

Code:

  READ PARM-FILE INTO W-PARM-REC.


Now WSZZ-PARM-DATE will just contain the date.

Now your sql should be as follows.


Code:

 SELECT *
   FROM PAT_ENC
   WHERE DATE(UPDATE_DATE) >= CONTACT_DATE
     AND DATE(UPDATE_DATE) <  :WSZZ-PARM-DATE


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group