New to SQL - Trouble getting quarterly date output

date postgresql sql sqlbulkcopy sql-insert

Question

I'm really new to sql and databases in general. Trying to teach myself the language but I'm stuck and would like to know what's wrong. So here's what I have:

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

...

And I'm inserting it into 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
;

This works. The problem is that when I select *, the output truncates the date. eg:

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

I need each quarter to show. This does not give me each quarter. Help appreciated. I'm using postgresql. Let me know if I need to provide more information.

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

Accepted Answer

Verify that you have the BD format must match the format that has the CSV file. Executing the following command in the console Postgesql:

SHOW datestyle;

Should return:

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

But it returns to modify the formatting is done with the following command:

SET datestyle = "ISO, YMD";

That Postgest version are you using?

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