We Recommend

SQL Cookbook SQL Cookbook
Written in O'Reilly's popular Problem/Solution/Discussion style, the SQL Cookbook is sure to please. Anthony's credo is: "When it comes down to it, we all go to work, we all have bills to pay, and we all want to go home at a reasonable time and enjoy what's still available of our days." The SQL Cookbook moves quickly from problem to solution, saving you time each step of the way.


Posted By

arunpjohny on 09/05/07


Tagged

postgres


Versions (?)


Date Add/Substract


Published in: SQL 


URL: http://www.postgresql.org/docs/8.0/interactive/functions-datetime.html

  1. /*
  2. * Subtracting months
  3. */
  4. UPDATE employee SET dateOfBirth = dateOfBirth - interval '1 months'
  5.  
  6. /*
  7. * Adding months
  8. */
  9.  
  10. UPDATE employee SET dateOfBirth = dateOfBirth + interval '1 months'
  11. /*
  12. * You can use one of the following intervals
  13. *--------------------------------------------
  14. * microseconds
  15. * milliseconds
  16. * second
  17. * minute
  18. * hour
  19. * day
  20. * week
  21. * month
  22. * quarter
  23. * year
  24. * decade
  25. * century
  26. * millennium
  27. */

Report this snippet 

You need to login to post a comment.