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

DB2 coalesce function for replacing null date


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Sanath sekhar Reddy N

New User


Joined: 31 Oct 2012
Posts: 30
Location: INDIA

PostPosted: Thu Jul 11, 2013 6:11 pm
Reply with quote

Hi

Could you please help me in resolving the below.
I have to replace the null value in date field in the table A
with 00.00.0000 .

Please can any one help me in time.


Regards
Sanath sekhar Reddy.N
Back to top
View user's profile Send private message
Auryn

New User


Joined: 11 Jan 2006
Posts: 67
Location: Lower Saxony (DE)

PostPosted: Thu Jul 11, 2013 6:33 pm
Reply with quote

If the type of the result column is DATE your desired value is not valid. The minimum valid date in DB2 z/OS is '01.01.0001'.
But if type of result column is CHAR(10) you can use
Code:
COALESCE(CHAR(my_date_col), '00.00.0000')
.
But pay attention of the result a date string containing 'DD.MM.YYYY'. It's better to use the reverse format 'YYYY.MM.DD'.
In above sample
Code:
COALESCE(CHAR(my_date_col), '0000.00.00')


If not every part of the date (or time as well) is known and you would like to store zeroes or spaces in that case you have to use a date string because i.e. date '00.12.2013' is invalid as well.
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 Uploading from desktop, a CSV file, s... DB2 2
This topic is locked: you cannot edit posts or make replies. A Rexx who changes date into a JCL?Po... CLIST & REXX 9
No new posts Date conversion using SORT SYNCSORT 4
No new posts Need Help with on of the coalesce query DB2 4
No new posts Date Conversion Y2T to Y2W SYNCSORT 8
Search our Forums:

Back to Top