How to decrement dates?

471 Views Asked by At

I have 2 dates: startDate= 6/22/2015 and endDate= 6/20/2015. I need to decrement these 2 dates, i meen endDate-startDate, so in this example I will get 2.

How can I do this in sql?

1

There are 1 best solutions below

0
On

The native way to do this would be to use the setDate method. There is an existing Stackoverflow post here: How to Add Dates

However, I always pass along the advice to use a date library, something like moment.js. In most languages, managing dates (timezones, leap years, etc ets) is incredibly difficult, and javascript can be even more so with browser time zone behaviors.