numpy datetime64 add or substract date interval

You can use the numpy.timedelta64 object to perform time delta calculations on a numpy.datetime64 object, see Datetime and Timedelta Arithmetic. Since a year can be either 365 or 366 days, it is not possible to substract a year, but you could substract 365 days instead: import numpy as np np.datetime64(‘2014-12-31′) – np.timedelta64(365,’D’) results in: numpy.datetime64(‘2013-12-31’)

how to get data of current week only in SQL server?

Do it like this: SET DATEFIRST 1 — Define beginning of week as Monday SELECT […] AND WorkDate >= dateadd(day, 1-datepart(dw, getdate()), CONVERT(date,getdate())) AND WorkDate < dateadd(day, 8-datepart(dw, getdate()), CONVERT(date,getdate())) Explanation: datepart(dw, getdate()) will return the number of the day in the current week, from 1 to 7, starting with whatever you specified using SET … Read more