Solved

googledoc spreadsheet last modified date

Posted on 2011-03-19
5
1,733 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
ID: 35173272
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
ID: 35184982
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
ID: 35190583
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
ID: 35191008
The ID is the string in the URL of the document between "key=" and "&"
0
 

Author Closing Comment

by:reggieperrin
ID: 35311687
Fantastic solution! Thank you so much!
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Redirect Website for Mobile Devises 9 106
ASP.NET gridview select textbox on focus 2 33
HTML5 Get data in table rows 5 27
HTML5 frame 5 25
Big data transfers via information superhighways require special attention and protection. Learn more about the IT-regulations of the country where your server is located. Analyze cloud providers and their encryption systems for safe data transit. S…
A customer recently asked me about anti-malware and the different deployment options available for his business. Daily news about cyberattacks, zero-day vulnerabilities, and companies that suffered a security breach made him wonder if the endpoint a…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
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, f…

776 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