Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2015
    Posts
    2

    Question Unanswered: ISDATE function DB2

    Hi Folks,

    I am newly learning DB2 and I have the following question. I want to know the date format of a column in a table and wants to retrieve the record if that is not in required date format like below query in sql

    IF ISDATE('2009-05-12') = 1
    PRINT 'VALID'
    ELSE
    PRINT 'INVALID'

    Thanks for you help in advance !!!

  2. #2
    Join Date
    Jul 2013
    Location
    Moscow, Russia
    Posts
    666
    Provided Answers: 55
    Hi,

    you can build it yourself like this:
    Code:
    create or replace function isdate(p_date varchar(32))
    returns int
    deterministic
    contains sql
    no external action
    begin
      declare exit handler for sqlexception return 0;
      return case when date(p_date) is not null then 1 else 0 end;
    end@
    Regards,
    Mark.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •