Friday, 23 August 2013

Postgres - Removing milliseconds from timestamp text

Postgres - Removing milliseconds from timestamp text

In my database we have a column that holds data in XML format. And one of
the XML elements holds dates that looks like this:
<timestamp>2013-05-22 16:01:26.78 CDT</timestamp>
<timestamp>2013-05-15 10:29:44.588 CDT</timestamp>
<timestamp>2013-02-27 09:37:54.677 CST</timestamp>
So I extracted the value between <timestamp> using:
substring(table.column from '<timestamp>(.*)</timestamp>') as "Time Stamp"
But I'm having a hard time trying to use regular expression to filter out
just the milliseconds. I don't know enough regular expressions to filter
out the milliseconds.

No comments:

Post a Comment