Tags: column, convert, database, date, datefield, db2, field, inmy, mysql, null, oracle, returns, spaces, sql, string

Convert Null in Date field to String

On Database » DB2

29,535 words with 10 Comments; publish: Fri, 04 Jan 2008 09:46:00 GMT; (25060.55, « »)

Hi,

My SQL returns a NULL in a datefield if there is no date in that field.

If there is a NULL in this column, I want to replace it with spaces in

my SELECT statement when I am selecting these records. Can any of you

experts out there help me with a sample SQL.

All Comments

Leave a comment...

  • 10 Comments
    • SELECT COALESCE(VARCHAR(datefield), '') FROM X...

      satishrajana.db2.todaysummary.com.gmail.com wrote:

      Quote:
      === Original Words ===

      Hi,

      >

      My SQL returns a NULL in a datefield if there is no date in that field.

      If there is a NULL in this column, I want to replace it with spaces in

      my SELECT statement when I am selecting these records. Can any of you

      experts out there help me with a sample SQL.

      #1; Fri, 04 Jan 2008 09:48:00 GMT
    • Thank you. I was trying the coalesce but did not cast it to VARCHAR.

      I really appreciate your help. It works now.

      Have a good day !

      jefftyzzer wrote:

      Quote:
      === Original Words ===

      Hi,

      My SQL returns a NULL in a datefield if there is no date in that field.

      If there is a NULL in this column, I want to replace it with spaces in

      my SELECT statement when I am selecting these records. Can any of you

      experts out there help me with a sample SQL.

#2; Fri, 04 Jan 2008 09:49:00 GMT
  • #3; Fri, 04 Jan 2008 09:50:00 GMT