If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > PostgreSQL > date fields in postgreSQL (DAY, MONTH, YEAR)

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-07-12, 09:39
sqlsuj sqlsuj is offline
Registered User
 
Join Date: Dec 2011
Posts: 4
Question date fields in postgreSQL (DAY, MONTH, YEAR)

Hi,

I want to select day, month and year out of a date field in PostgreSQL.

The field is datecalc.

I moved this query from MS SQL Server to Postgres so I could access the right table.

Here is the query? does anyone know how I can change this to work?

select l.id, l.primaryname, DAY(lp.calcdate) as day, lp.popularity, lp.categorypopularity
from t_location l left join
t_location_popularity_history lp on l.id=lp.locationid
where YEAR(lp.calcdate)=2011 and l.id in (1818266,
224770)
group by l.id, l.primaryname, DAY(lp.calcdate), lp.popularity, lp.categorypopularity
Reply With Quote
  #2 (permalink)  
Old 02-07-12, 11:00
futurity futurity is offline
Registered User
 
Join Date: May 2008
Posts: 270
Use the EXTRACT function.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On