Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2011
    Posts
    4

    Question Unanswered: 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

  2. #2
    Join Date
    May 2008
    Posts
    277
    Use the EXTRACT function.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •