SQL current time stamp Where you select a specific day from the month before the present

0

I am looking for a way to compare a data from my table in SQL server to get the list of records from a date

SELECT * FROM asistencias where fecha >= (CURRENT_TIMESTAMP-15)

(shows the current results of the current date -15 days)

my real query is:

SELECT * FROM asistencia where id_usuario=$Id_usuario and fecha > '2018-07-25' and fecha < '2018-08-25' and asistencia = '0'

as the current period has to be automatic the dates have to be generated logically

    
asked by claus 30.07.2018 в 23:30
source

1 answer

2

Using DAY(15) you can subtract or add the days. It would be something like this:

SELECT * 
FROM asistencia 
WHERE id_usuario=$Id_usuario AND 
      fecha > GetDate()-DAY(15) AND 
      fecha < GetDate()+DAY(15) AND 
      asistencia = '0'
    
answered by 31.07.2018 в 13:38