Comment obtenez-vous les 30 jours avant aujourd'hui en SQL.
T-SQL
declare @thirtydaysago datetime
declare @now datetime
set @now = getdate()
set @thirtydaysago = dateadd(day,-30,@now)
select @now, @thirtydaysago
ou plus simplement
select dateadd(day, -30, getdate())
[~ # ~] mysql [~ # ~]
SELECT DATE_ADD(NOW(), INTERVAL -30 DAY)
Dans MS SQL Server, c'est:
SELECT getdate() - 30;
SELECT (column name) FROM (table name) WHERE (column name) < DATEADD(Day,-30,GETDATE());
Exemple.
SELECT `name`, `phone`, `product` FROM `tbmMember` WHERE `dateofServicw` < (Day,-30,GETDATE());