How do I get the posts within a certain year/date(with sql query)?

Try this for posts from last 1 year:

AND ( 
  post_date_gmt < DATE(NOW()-INTERVAL 1 YEAR)
  ) 

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)