Cannot get date from google sheet filled by google forms -
Purpose: To remove date and time from the sheet (created by filling Google Forms) and sending them to the body of the e-mail Automatically use script to set script editor code:
sendEmails function () {var sheet = SpreadsheetApp.getActiveSheet (); Var startRow = 16; // var numRows = 1 first row of data to process; // Number of rows for processes (var j = startrow; j & lt; startRow + numrows; j ++) {var color = sheet.getrange (j, 10) .getBackground (); Get a range of ("# 00ff00" == color) {// cell A2: B3 var row = sheet.getSheetValues (j, 1, 1, 14); // J row with 14 / NSE color names with stdents = row [0] [0] + "" + row [0] [1]; Var time = line [0] [6] + "at"; // + row [0] [7] + "at" + row [0] [8]; Var named = "Dear" + row [0] [9] + ","; Var email receipt = line [0] [13]; Var topic = "date and time" + line [0] [5] + "at" + row [0] [6]; Var msg = nameRecipient + sheet.getRange ("L11"). GetValue () + nameStudent + sheet.getRange ("M11") getValue () + Time + Name Student + Sheet.GetRnZ ("N11"). GetValue (); MailApp.sendEmail (email receipt, subject, message); Sheet.getRange (J, 10) .setBackground ("#FF9900"); }}}
In output (i.e. e-mail):
The date is filed by the person who fills the Google form. I created the form using Google Screenshot of sheet accessing sheet: Cell (when double clicked) opens the calendar shown on the screenshot above. I use the following code (using Google Apps Script) to get a line from the sheet:
var line = sheet.getSheetValues (j, 1, 1, 14 ); The J line looks like the date of extracting the line from [["Gaaav", "Budapest", " De@erta.com ", 9823527827," San Francisco International Airport (SFO) ", 41855, 0.5277777777810115," C 0016 "," Al 02 "," Man "," Public Relations "," 3112 ", 94984802569," JClfusz @ Kgsesfacl .com "]]
Number 41855 is the date in the above statement. This is actually 8/4/2014 but I can not read it, neither can I read the time, which is 0.5277777777810115 in above debug O / P.
I am attaching a screenshot of the debug screen:
Assuming submitting your time is 14 in your spreadsheet.
Change both the date and time values in the Javascript date objects, then update the form with the date object form with the hour and minute time objects.
function sendEmails () {var sheet = SpreadsheetApp.getActiveSheet (); Var startRow = 16; // var numRows = 1 first row of data to process; // Number of rows for processes (var j = startrow; j & lt; startRow + numrows; j ++) {var color = sheet.getrange (j, 10) .getBackground (); Get a range of ("# 00ff00" == color) {// cell A2: B3 var row = sheet.getSheetValues (j, 1, 1, 14); // J row with 14 / NSE color names with stdents = row [0] [0] + "" + row [0] [1]; Var time = line [0] [6] + "at"; // + row [0] [7] + "at" + row [0] [8]; Var named = "Dear" + row [0] [9] + ","; Var email receipt = line [0] [13]; // Prepare the date time object var dateInput = New date (line [0] [5]); Var Time Input = New Date (line [0] [6]); DateInput.setHours (timeInput.getHours ()) dateInput.setMinutes (timeInput.getMinutes ()); // String var dateString = Utilities.formatDate (dateInput, Session.getScriptTimeZone), "MM / dd / yyyy hh: mm a" Format date / time object;); Var topic = "date and time" + date string var message = name recieve + sheet.gaterenz ("L11"). GetValue (+) + Extend + Sheet.GetRenz ("M11"). GetValue () + Time + NameHydient + Sheet.GetRenz ("N11") getValue () .; MailApp.sendEmail (email receipt, subject, message); Sheet.getRange (J, 10) .setBackground ("#FF9900"); }
}}
Comments
Post a Comment