New to SQL - Trouble getting quarterly date output

date postgresql sql sqlbulkcopy sql-insert

Question

I'm a complete novice when it comes to databases and SQL. I'm trying to learn the language on my own, but I'm having trouble and would want to know why. This is what I have, then:

1976-01-01,6.1
1976-04-01,5.7
1976-07-01,5.7
1976-10-01,5.8

...

Additionally, I'm adding it to a table.

CREATE TABLE "va unem"
    (Date DATE NOT NULL PRIMARY KEY, Val REAL   
);

``

COPY "va unem"
    FROM 'C:\Users\Public\Documents\SQL\fred\vsaur.csv'
    DELIMITER ',' 
    CSV
;

That works. The issue is that whenever Iselect * the date is truncated in the output. eg:

1|1976|6.1
2|1976|5.7
3|1976|5.7
4|1976|5.8
...

I need a showing every quarter. This does not provide me every three months. Much-needed assistance I employ Postgresql. Please let me know if you need any other details.

1
1
5/15/2013 9:15:35 PM

Accepted Answer

Make that your BD format corresponds to the format of the CSV file. the following command on the Postgesql console:

SHOW datestyle;

Should come back:

  dateStyle
-----------
  ISO, YMD
(1 row)

But it does so again to change the formatting with the following command:

SET datestyle = "ISO, YMD";

What version of Postgest do you use?

2
5/15/2013 10:02:43 PM


Related Questions





Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow