dbTalk Databases Forums  

Re: Date conversion from mmddyy to ccyymmdd within SQL?

ibm.software.db2.os400 ibm.software.db2.os400


Discuss Re: Date conversion from mmddyy to ccyymmdd within SQL? in the ibm.software.db2.os400 forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
B.Hauser
 
Posts: n/a

Default Re: Date conversion from mmddyy to ccyymmdd within SQL? - 08-11-2006 , 10:18 AM






Hi,

I assume, you want to convert a numeric date with the format MMDDYY into an other numeric date with the format of YYYYMMDD.

SQL provides no function to convert this directly, but you may use the following statement to convert from numeric MMDDYY to numeric YYYYMMDD.

<pre>
Select Cast(case when Substr(digits(MyMMDDYY), 5, 2)
between '40' and '99'
then '19' Else '20' End
concat Substr(digits(MyMMDDYY), 5, 2)
concat Substr(digits(MyMMDDYY), 1, 4) as Dec(8, 0))
From MyTable
</pre>

Birgitta

Reply With Quote
  #2  
Old   
 
Posts: n/a

Default Re: Date conversion from mmddyy to ccyymmdd within SQL? - 08-11-2006 , 12:59 PM






That will do the trick. Thanks!

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.