in reply to Months between dates ?

Hi bgroper

Although we love doing stuff in perl – if it's all the same, why not adjust your query so that your result set contains only that which you're interested in? a la SELECT statement below:

-- table set up CREATE TABLE test( test_id INTEGER ,date_tstamp TIMESTAMP NOT NULL DEFAULT LOCALTIMESTAMP ,CONSTRAINT test_test_id_pkey PRIMARY KEY (test_id) ); INSERT INTO test VALUES (1,now()) ,(2,now()) ,(3,now()) ,(4,now() + INTERVAL '60 days') ,(5,now() + INTERVAL '70 days') ; -- select statement SELECT date_tstamp FROM test WHERE date_tstamp > (now() + INTERVAL '59 days');

Best regards,
Shadowsong

Replies are listed 'Best First'.
Re^2: Months between dates ?
by bgroper (Novice) on Jun 10, 2019 at 09:12 UTC
    Thanks for the excellent suggestion.
    I agree, its much easier to do this with the SELECT statement, and then simply show the *Alert* if SELECT returns any result/s.
    Nice. :-)