0

I'm novice in PostgreSQL. I have a column timestamp without time zone named FailureTime. At the beginning it has NULL value.

When SELECT I need to get all entries that has current_timestamp - FailureTime > interval '7'.

But when FailureTime is NULL the result of operation is NULL. Can I cast NULL to ZERO value or somehow get just current_timestamp as result of the operation?

1
  • Why don't you add FailureTime IS NOT NULL in your "WHERE" clause ? Commented May 23, 2013 at 17:38

2 Answers 2

2
current_timestamp - coalesce(FailureTime, current_timestamp) > interval '7'
Sign up to request clarification or add additional context in comments.

Comments

1

You can exclude NULL elements by specifying something like:

SELECT ... 
WHERE (FailureTime IS NOT NULL) 
AND (current_timestamp - FailureTime > interval '7')

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.