Solved

googledoc spreadsheet last modified date

Posted on 2011-03-19
5
1,692 Views
Last Modified: 2012-08-13
I am writing a script in a google doc spreadsheet that needs to check the last modified date of another google doc spreadsheet. How can I retrieve the last modified date of a google doc spreadsheet if I know its URL or key already?
0
Comment
Question by:reggieperrin
  • 3
  • 2
5 Comments
 
LVL 5

Expert Comment

by:torvir
Comment Utility
I tried it and got it to work with this script. The first line "var thisSheet..." and the last line are used only to be able to print the date in the present spreadsheet cell A1.
The file I am checking change date of is the file named "fileToCheckChangeDateUpon" which is a dummy file I created.

function dateOfTestfile() {
  var thisSheet = SpreadsheetApp.getActiveSheet();
  var files = DocsList.getFiles();
  var otherFileChangeDate = "Didn't find it";
  for (var n = 0; n < files.length; n++) {
    if (files[n].getName() == "fileToCheckChangeDateUpon") {
      otherFileChangeDate = files[n].getLastUpdated();
      break;
    }
  }
  thisSheet.getRange(1, 1).setValue(otherFileChangeDate);
}
0
 

Author Comment

by:reggieperrin
Comment Utility
You rock! I tried your solution and it worked! However it is taking too long to go through all my files. How would I get it to only add jobs that start with "Job" into the files[n] array, before it starts searching through them?
0
 
LVL 5

Accepted Solution

by:
torvir earned 500 total points
Comment Utility
If you know the file-ID you could use this syntax:
var file = DocsList.getFileById("t314159");

The script then becomes:

function dateOfTestfile() {
  var thisSheet = SpreadsheetApp.getActiveSheet();
  var file = DocsList.getFileById("t314159");
  var otherFileChangeDate = file.getLastUpdated();
  thisSheet.getRange(1, 1).setValue(otherFileChangeDate);
}
0
 
LVL 5

Expert Comment

by:torvir
Comment Utility
The ID is the string in the URL of the document between "key=" and "&"
0
 

Author Closing Comment

by:reggieperrin
Comment Utility
Fantastic solution! Thank you so much!
0

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Join & Write a Comment

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now