Re: Inputting relative datetimes - Mailing list pgsql-hackers

From Jeff MacDonald
Subject Re: Inputting relative datetimes
Date
Msg-id 201108270929.16828.jam@zoidtechnologies.com
Whole thread Raw
In response to Inputting relative datetimes  (Dean Rasheed <dean.a.rasheed@gmail.com>)
Responses Re: Inputting relative datetimes
List pgsql-hackers
Greetings,

On Thursday, August 25, 2011 05:39:09 AM Dean Rasheed wrote:
> As background, I have an app that accepts user text input and casts it
> to a timestamp in order to produce reports. I use PostgreSQL's
> timestamp input conversion for this, since it gives a lot of
> flexibility, and can parse pretty much anything the users throw at it.
> 
> It is also handy that it recognizes special case values like "now",
> "today", "tomorrow" and "yesterday". However, I can't see any way of
> entering more general relative timestamps like "5 days ago" or "2
> hours from now".
> 

Years ago I wrapped 'getdate.y' from the CVS source code and made it into a 
python extension. It handles "+2 hours" or "next week", etc. I don't know much 
of anything about making pg contrib modules, but it should not be hard to do. 
The way it works is you pass in a string and it returns the unix timestamp.

[...snipped...]
> 
> Thoughts?
> Better ideas?
> 
> Regards,
> Dean

Regards,
J


pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: Inputting relative datetimes
Next
From: "Tomas Vondra"
Date:
Subject: Re: PATCH: regular logging of checkpoint progress