0

How can I convert 'dd-MM-yyyy HH:mm:ss.fff' to 'yyyy-MM-dd HH:MI:SS.MS' format so that I can store timestamp values in a PostgreSQL 8.0.2 timestamp column?

4
  • Ok, slowly: You have character fields containing the given format and want to convert them to a Timestamp? Commented Feb 23, 2013 at 7:54
  • More context please. Convert them within Postgres? In your programming language of choice (which?!) before inserting into Postgres? Commented Feb 23, 2013 at 7:55
  • Thanks, i'm uploading application generated csv files to Amazon S3 and using copy command, the data from the files are inserted into PostgreSql tables. I've made changes to my app. to generate YYYY-MM-DD HH:MM:SS.fff format text, but the problem is i want to upload the existing files that are already generated with DD-MM-YYYY HH:MM:SS.fff format and don't want to regenerate them. Commented Feb 23, 2013 at 8:39
  • If PostgreSQL 8.0.2 isn't a typo, you have more serious problems than formatting timestamps. v8.0 has reached EOL in 2010. Consider upgrading to a more current version. Commented Feb 23, 2013 at 16:55

1 Answer 1

1

Presumably you don't have to convert the format, just switch to european datestyle before issuing COPY.

The command is:

SET datestyle to 'DMY';
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.