Question: Is there a way to display all records from let's say last Thursday until today in mysql?
I found all records from last week, all records in certain interval of days but nothing for a fixed day last week and all this week...
Our records always begin on Thursday that's why i'm asking

**Edit:**
This week (no matter if it is Monday to Friday) i want to see all records from last Thursday until NOW(). Next week the whole process repeats but must display records from this Thursday until the day (Monday to Friday) next week... and so on.

Answer: 
I am personally in favor of using unique indexes instead of a constraint for cases like this. I have found that columns I want to be unique I probably want an index anyways, so 2 birds with 1 stone. So I would do this:

```
CREATE UNIQUE NONCLUSTERED INDEX [uidx_dealid_sent] ON [dbo].[Snapshot]
(
    [dealid] ASC,
    [sent] ASC
)
WHERE ([sent]=0)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO

```

The compound unique index does what you are looking to do: You won't be able to insert a row where a specific `dealid` and specific `sent` already exist together. As Larnu pointed out, this should be a filtered index (for MSSQL 2008 and later). Notice the `WHERE ([sent]=0)`, this should satisfy your requirement for only wanting to apply the rule when `sent = 0`.
For what it's worth, the reason you were getting the error with your code is because when a CHECK CONSTRAINT calls a function, the function code assumes that the row that is triggering the call has already been created/inserted/updated.

So in your function you are testing whether there are zero rows that have `Sent=0`. The row being inserted COUNTS as a row in the table already, so if you only allow zero rows to have `Sent=0` then you will never be able to insert even a single row with `Sent=0`.

To do what you want, you should have only allowed one row per id to have `Sent=0`.