Search code examples
google-apigoogle-drive-api

Google Drive API Get files of the last week/last Day


I'm looking for property in google drive API to get google spreadsheet file that's I upload them last week

this URL gives all the files that I have on my google drive. I want to filter this URL more with TIME Per week

https://www.googleapis.com/drive/v3/files?q=mimeType='application/vnd.google-apps.spreadsheet'&access_token=",$access_token$

any help will be gratefully received.


Solution

  • I think that @DaImTo's answer is correct. So how about this workaround? When the files are uploaded to Google Drive, the created time and modified time become the same to the uploaded time. In this workaround, this is used.

    From your question, it seems that you use Drive API v3. So you can use the following query. As a sample, it assumes that the last week is 2018-04-01T00:00:00.

    mimeType='application/vnd.google-apps.spreadsheet' and modifiedTime > '2018-04-01T00:00:00' and createdTime > '2018-04-01T00:00:00'
    

    Note :

    • Please modify the date to your environment.
    • If you want to retrieve files using the range of date, please modify as follows.
      • mimeType='application/vnd.google-apps.spreadsheet' and modifiedTime > '2018-04-01T00:00:00' and modifiedTime < '2018-04-02T00:00:00' and createdTime > '2018-04-01T00:00:00' and createdTime < '2018-04-02T00:00:00'
      • This means that files uploaded from 2018-04-01T00:00:00 to 2018-04-02T00:00:00 are retrieved.
    • In the case of this workaround, it cannot be known whether those are the files that had been uploaded. If you manually created files for 1 week, this query also retrieves such files.
      • If you want to retrieve only the uploaded files, how about using the unique filename? For example, it's upload-###. By this, you can use the following query.
        • mimeType='application/vnd.google-apps.spreadsheet' and modifiedTime > '2018-04-01T00:00:00' and createdTime > '2018-04-01T00:00:00' and name contains 'upload-'

    Reference :

    I'm not sure whether this is useful for your environment. So if this was not useful for you, I'm sorry.