473,474 Members | 1,682 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Date Check in DB2 UDB urgent

Hi All,

I have varchar column which stores data in 8 char format 'yyyymmdd'. i
want to transfer data in date columns but before that i want to check
data is proper date or not.

like in sql server i have isdate function. i didnt seen any function
like that in DB2 UDB. can any one have UDF return to check date in DB2.
please suggest any other way,

thanks
Suresh

Aug 30 '06 #1
2 12900
How about this?

CREATE FUNCTION ISDATE(yyyymmdd VARCHAR(8))
RETURNS INTEGER
LANGUAGE SQL
CONTAINS SQL
DETERMINISTIC
NO EXTERNAL ACTION
RETURN
CASE
WHEN TRANSLATE(yyyymmdd, '*', ' 0123456789') = '' THEN
CASE
WHEN SUBSTR(yyyymmdd,1,4) BETWEEN '0001' AND '9999'
AND SUBSTR(yyyymmdd,5,2) BETWEEN '01' AND '12'
AND INT(SUBSTR(yyyymmdd,7,2))
<=
DAY(DATE(CHAR(INSERT(SUBSTR(yyyymmdd,1,6),5,0,'-')||'-01',10)) + 1
MONTH - 1 DAY)
THEN 1
ELSE 0
END
ELSE 0
END;

Aug 30 '06 #2
Need (at lest) one correction)
"dd" should be checked lower limit(i.e. '01')

CREATE FUNCTION ISDATE(yyyymmdd VARCHAR(8))
RETURNS INTEGER
LANGUAGE SQL
CONTAINS SQL
DETERMINISTIC
NO EXTERNAL ACTION
RETURN
CASE
WHEN TRANSLATE(yyyymmdd, '*', ' 0123456789') = '' THEN
CASE
WHEN SUBSTR(yyyymmdd,1,4) BETWEEN '0001' AND '9999'
AND SUBSTR(yyyymmdd,5,2) BETWEEN '01' AND '12'
AND INT(SUBSTR(yyyymmdd,7,2)) BETWEEN
1 AND
DAY(DATE(CHAR(INSERT(SUBSTR(yyyymmdd,1,6),5,0,'-')||'-01',10))
+ 1 MONTH - 1 DAY)
THEN 1
ELSE 0
END
ELSE 0
END;

Aug 30 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Stefan Bauer | last post by:
Hi NG, we've got a very urgent problem... :( We are importing data with the LOAD utility. The input DATE field data is in the format DDMMYYYY (for days) and MMYYYY (for months). The target...
9
by: Shapper | last post by:
Hello, I created a dataset from a XML file. One of the dataset fields is . In an ASP:Repeater I am displaying the field. <%# DataBinder.Eval(Container.DataItem, "pubDate", "{0:f}") %> The...
2
by: Naga Kiran | last post by:
Hi I want to set expiration date for my web based application. for eg it has to be worked for 15 days from the date when it was installed. More over i dont want to use system date to check the...
2
by: Naga Kiran | last post by:
Hi i want to set expiration date for my web based application. for eg it has to be worked for 15 days from the date when it was installed. More over i dont want to use system date to check the...
4
by: sck10 | last post by:
Hello, I created an ashx file for my rss feed (rss.ashx). I notice on the site (http://rss.msnbc.msn.com/id/3032091/device/rss/rss.xml) that the date (Yesterday, October 30, 2006, 3:02:37 PM)...
1
by: kunal0101 | last post by:
Hi, I am a new user to access and am building a database to capture the rotation dates for employees. There is a table called "Rotation schedule" which contains "name", "Duration (in weeks) and...
7
by: =?Utf-8?B?U3R1?= | last post by:
I have a ASP.NET Ajax app (using client library) calling ASP.NET Ajax-enabled web services. We are making use of the javascript proxies generated by ASP.NET Ajax. The problem we have is that the...
0
by: Sreenath Rao Nellutla | last post by:
Hai All, 1. I need help regarding displaying Date in to DataGrid from SQL Server 2000 database in the required format. Sql Server data : smalldatetime DataGrid : Date (Only I want. But...
7
by: shivasusan | last post by:
Hello Friend! I am new for ASP. Database is Microsoft Access. So pls help me..... My problem is --- 1. In login page, two text boxs. first textbox is username & second textbox is...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.