Filtering for "updated_at"?

How would I use the api to get a version updated_at more than 30 days ago?

What do I pass to that filter?

2 Likes

Hi Ricardo

I think this is what you are looking for:

from pprint import pprint, pformat
from datetime import datetime, timedelta

days_ago = 30
# get a date object for x number of days ago
date_x_days_ago = datetime.now() - timedelta(days=days_ago)

# find users by checking the user's projects field
versions = shotgun.find("Version",
                        [["project.Project.id", "is", 89],
                         ["updated_at", "less_than", date_x_days_ago]],
                        ["code", "updated_at"])
pprint(versions)

It’s not whole days, it’s using the current time as well so you would get a split of versions on that day depending what time you run this script at and when the versions were created. You could alter the datetime object though so you always went from midnight or something though.
Best
Phil

2 Likes

Awesome!

I’m going to try that out! :slight_smile:

2 Likes