Fun with Dates

From: Mark Fenbers <mark(dot)fenbers(at)noaa(dot)gov>
To: pgsql-sql(at)postgresql(dot)org
Subject: Fun with Dates
Date: 2012-10-29 22:38:46
Message-ID: 508F0576.4020404@noaa.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Greetings,

I want to be able to select all data going back to the beginning of the current month. The following portion of an SQL does NOT work, but more or less describes what I want...

... WHERE obstime = NOW() - INTERVAL (SELECT EXTRACT (DAY FROM NOW() ) ) + ' days'

In other words, if today is the 29th of the month, I want to select data that is within 29 days old... WHERE obstime = NOW() - INTERVAL '29 days'

How do I craft a query to do use a variable day of the month?

Mark

Attachment Content-Type Size
unknown_filename text/html 774 bytes
mark_fenbers.vcf text/x-vcard 347 bytes

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Thomas Kellerer 2012-10-29 22:44:01 Re: Fun with Dates
Previous Message David Johnston 2012-10-28 14:54:12 Re: pull in most recent record in a view