• Welcome to the Chevereto user community!

    Here users from all over the world gather around to learn the latest about Chevereto and contribute with ideas to improve the software.

    Please keep in mind:

    • This community is user driven. Be polite with other users.
    • We recommend purchasing a Chevereto license to participate in this community.
    • Purchase a Community Subscription to get even faster ticket response times.
  • Chevereto Support CLST

    Support response

    Support checklist

    • Got a Something went wrong message? Read this guide and provide the actual error. Do not skip this.
    • Confirm that the server meets the System Requirements
    • Check for any available Hotfix - your issue could be already reported/fixed
    • Read documentation - It will be required to Debug and understand Errors for a faster support response

Get total number of images uploaded in one month ? SQL Query?

AshleyUK

💖 Chevereto Fan
Hi,
Is there a way to find out the total number of uploaded images in one given month?
For example, I want to find out how many images were uploaded in April 2016.
Is there a suitable SQL Query that I can run to give me this information?

Thanks
 
There are a few different approaches, would be something along the lines of ....

SELECT COUNT(image_date) FROM chv_images
WHERE image_date >= DATEADD(DAY,-30, GETDATE())

SQL COUNT can be a bit funny sometimes, it would be safer and cleaner to make a little PHP script then use that to count the images.

Also, image_date is a datetime field, which can also confuse SQL if it's not formatted first

"SELECT DATE_FORMAT(image_date,'%m/%d/%Y')
FROM chv_images
WHERE image_date BETWEEN NOW()- INTERVAL 30 DAY AND NOW()"

Then using PDO query ...

$no_images= $query->rowCount();

Which will return the number of rows within the 30 day time-frame

EDIT:

I just re-read your question, you wanted everything from a given month .....

"SELECT image_date FROM chv_images WHERE image_date BETWEEN '2016-04-01 00:00:00' AND '2016-04-30 23:59:59' ";

Would return the whole of April.

So many ways to do this :/
 
Last edited:
Wow... 490,000 rows in the last 30 days.
So I take it that means, 490,000 images have been uploaded in the last 30 days?
 
I've just confirmed it with changing the number of days to 999, and comparing the amount of images in the admin area to the count from SQL... It's not 'exact' but it's very very close. I have nearly 6 million uploaded images. 🙂
 
COUNT will skip things it doesn't like, such as NULL fields, or badly formatted dates, so it may not be 100%, but as you say, it should be close enough.

Glad it helped 😀
 
Back
Top