View previous topic :: View next topic
|
Author |
Message |
cpuhawg
Active User
Joined: 14 Jun 2006 Posts: 331 Location: Jacksonville, FL
|
|
|
|
I have an FB/80/27920 dataset:
Code: |
ABCDE 2007-12-15
DEFGH 2008-01-14
QRSTU 2008-08-06
IJKLM 2007-10-02
NOPQR 2008-06-18
|
The date is in position 7 in a yyyy-mm-dd format
How would I write an INCLUDE statement to select records whose date is less than current date? |
|
Back to top |
|
|
Ganesh.Deokar
New User
Joined: 30 Sep 2005 Posts: 26 Location: Buffalo,NY
|
|
|
|
Try these control statements in your SYSIN:
Code: |
//SYSIN DD *
SORT FIELDS=COPY
INCLUDE COND=(1,10,CH,LT,DATE4)
/* |
|
|
Back to top |
|
|
Ganesh.Deokar
New User
Joined: 30 Sep 2005 Posts: 26 Location: Buffalo,NY
|
|
|
|
Hi,
I should have used INCLUDE COND=(7,10,CH,LT,DATE4) as the date starts in position 7.
Regards,
Ganesh |
|
Back to top |
|
|
cpuhawg
Active User
Joined: 14 Jun 2006 Posts: 331 Location: Jacksonville, FL
|
|
|
|
Thank you for your assistance. The solution worked perfectly.
Scott |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Hmmm
Really, a better (more general) choice would be:
Code: |
INCLUDE COND=(7,10,CH,LT,DATE1(-))
|
which generates a 10-byte 'yyyy-mm-dd' date.
Code: |
INCLUDE COND=(7,10,CH,LT,DATE4)
|
will work for a yyyy-mm-dd date, but not for a date with any other separation character. DATE4 actually generates a 19-byte date in the form 'yyyy-mm-dd-hh.mm.ss'. 1,10 results in only using the first 10 bytes of that date. And there's no way to use another separation character with DATE4, so it wouldn't work for a 'yyyy.mm.dd' date, for example.
DATE1(-) generates a 10-byte date in the form 'yyyy-mm-dd. DATE(.) generates a 10-byte date in the form 'yyyy.mm.dd'. And so on. So DATE1(c) is really the more general choice and avoids the overhead of truncating the constant to the field length. |
|
Back to top |
|
|
mkk157
Active User
Joined: 17 May 2006 Posts: 310
|
|
|
|
Hi Frank,
Here we are comparing the Dates in the file with the CURRENT DATE.
But In case IF we want to compare the date like 2007-06-15, then how will be the sort card. where do we need to store the date 2007-06-15.
and what is the case if the date is in YYMMDD and we want to compare these dates coming from the input file with the 2007-06-15 date format. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
You say "where do we need to store the date 2007-06-15". Are you trying to avoid "storing" it in the INCLUDE statement as a constant?
Code: |
INCLUDE COND=(p,m,f,EQ,C'date')
|
You could store it in a file as a DFSORT symbol:
MYDATE,'2007-06-15'
and use that symbol in the INCLUDE statement:
Code: |
//SYMNAMES DD DSN=...
...
//SYSIN DD *
INCLUDE COND=(p,m,f,EQ,MYDATE)
|
or store just the date in a file, and use DFSORT to create a DFSORT symbol from that file (I've shown many examples of this).
If you want to compare it to a YYMMDD date, why wouldn't you "store" it as a YYMMDD date instead of as a 'YYYY-MM-DD' date? If you need to store it as a 'YYYY-MM-DD' date, you could use DFSORT to create a YYMMDD date from it.
If that doesn't help, please explain more clearly what is you want to do exactly. |
|
Back to top |
|
|
Prabha Warnings : 2 New User
Joined: 05 Dec 2005 Posts: 79
|
|
|
|
Can u pls explain how to store that date with code.. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Quote: |
Can u pls explain how to store that date with code.. |
I don't know what you mean by this. |
|
Back to top |
|
|
krisprems
Active Member
Joined: 27 Nov 2006 Posts: 649 Location: India
|
|
|
|
mkk157
Guess you are looking for this!!
Code: |
INCLUDE COND=(7,10,CH,LT,C'2007-12-15') |
|
|
Back to top |
|
|
|