Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Date in descending order for a query

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
amitkumar_sindhi

New User


Joined: 20 May 2005
Posts: 8

PostPosted: Wed Feb 01, 2006 11:00 pm    Post subject: Date in descending order for a query
Reply with quote

Hi,

I have following cursor

EXEC SQL
DECLARE OPCONUM-CSR CURSOR FOR
SELECT PCRD_OPCO
,PCRD_PCARD
,PCRD_RUN_DATE
,PCRD_AMOUNT
,PCRD_STATUS
,PCRD_SEQ
FROM R71DB2.PROC_CARD_DTL
WHERE PCRD_OPCO = :PCRD-OPCO
UNION
SELECT PCRH_OPCO
,PCRH_PCARD
,PCRH_RUN_DATE
,PCRH_AMOUNT
,PCRH_STATUS
,PCRH_SEQ
FROM R71DB2.PROC_CARD_HIST
WHERE PCRH_OPCO = :PCRH-OPCO
ORDER BY 5,3 DESC
FOR READ ONLY
END-EXEC.

here PCRD_RUN_DATE,PCRH_RUN_DATE is MMDDYYYY format, so
if there are two dates 12/09/2005, 02/01/2006 the output
of the query will not give the dates in the descending order
as it will compare 12092005 with 02012006 and
hence 12092005 will come first though 02012006 is greater.
is there any date function that can be used? so that the
dates can be get in descending order i.e. is it possible to change the
format to YYYYMMDD while ordering?, but in the output date should be in the format mm-dd-yyyy.

Regards,
Amit
Back to top
View user's profile Send private message

prabs2006

Active User


Joined: 12 Jan 2006
Posts: 103

PostPosted: Thu Feb 02, 2006 12:17 pm    Post subject:
Reply with quote

Hi Amit,

Try this and let me know it works..

CHAR(PCRD_RUN_DATE, ISO)

CHAR(PCRH_RUN_DATE, ISO)


Thanks & Regards
Prabs
Back to top
View user's profile Send private message
Mane Sagar

New User


Joined: 12 Jul 2005
Posts: 41
Location: mumbai

PostPosted: Sat Feb 04, 2006 2:19 pm    Post subject:
Reply with quote

Hi,

Can anyone please solve my query

I want to accept the system date.

ACCEPT WS-DATE FROM DATE.
This is in the form YYMMDD.

Can we get CC too as CCYYMMDD from the system

Please clarify.
Rgds,
SaMa
Back to top
View user's profile Send private message
prabs2006

Active User


Joined: 12 Jan 2006
Posts: 103

PostPosted: Mon Feb 06, 2006 12:14 pm    Post subject:
Reply with quote

Hi Mane,

There is a function in cobol but confirm it with TSO QW (help) from ur mainframes.

Function current_timestamp

This is a 21 byte field which will tell u till microsec .Use reference to get the format as u need it. BTW, I am uncertain whether that shud be a hyphen or underscore

Thanks & Regards
Prabs
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm
No new posts LISTIDR compiled date/time jerryte IBM Tools 3 Thu Apr 20, 2017 7:37 pm
No new posts SUBSTR for Date functions Shaheen Shaik DB2 4 Thu Apr 06, 2017 2:14 pm
No new posts Date and time format in CICS Chandru3183 CICS 2 Sat Mar 18, 2017 12:46 pm
No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us