How to compare dates from two tables with blanks values

From: Mike Martin <redtux1(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: How to compare dates from two tables with blanks values
Date: 2018-12-19 10:41:19
Message-ID: CAOwYNKZqi9L4mT3B1FEAQEoT47NLuGJtyR5ZB58nFFDBseUpLQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have a situation where I need to update dates in a primary table from
regular imports of data, eg: this is the base select query

select d.row_id,
fname||lname,'joineddate',d.joineddate,'joineddate',s.joineddate,0 as bool1
from import s join members d on d.contact_id=s.contact_id where

cast(nullif(d.joineddate,NULL) as timestamp) !=
cast(nullif(s.joineddate,'') as timestamp)

This gives zero records, however I cant seem to get a query that works.
For non-date fields I just use
Coalesce(fieldprime,'')!=coalesce(fieldiimport,'') which works fine but
chokes on dates where there is a blank value

thanks in advance

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Arnaud L. 2018-12-19 10:57:38 Re: How to compare dates from two tables with blanks values
Previous Message Condor 2018-12-19 08:12:04 Re: Format an Update with calculation