Date Add/Substract


/ Published in: SQL
Save to your folder(s)



Copy this code and paste it in your 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. */

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.