Jump to content

SQL help


Alisha

Recommended Posts

Hello,

What's the correct SQL to display information from the past 7 days please? I'm trying to create a List of Data widget.

I have used BETWEEN CURRENT_DATE -7 AND CURRENT_DATE but this has given me results from last year as well as this year.

When I used >=CURRENT_DATE -7 that gave me today's information as well as the previous 7 days.

Many thanks,
Alisha

Link to comment
Share on other sites

@Alisha I'm stretching my SQL here, but I would think

datetimecol BETWEEN CURRENT_DATE() + INTERVAL -1 DAY AND CURRENT_DATE() + INTERVAL -8 DAY

would do it - assuming you want a full week (7 days) of data up to but not including today. You can tweak the -1 and -8 according to the results you get.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...