IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Date in descending order for a query


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts RC query -Time column CA Products 3
No new posts Need to convert date format DFSORT/ICETOOL 20
No new posts Rotate partition-logical & physic... DB2 0
Search our Forums:

Back to Top