function format_date(date){
var date = date;
var yyyy = date.getFullYear().toString();
var mm = (date.getMonth()+1).toString();
var dd = date.getDate().toString();
var mmChars = mm.split('');
var ddChars = dd.split('');
var datestring = yyyy + (mmChars[1]?mm:"0"+mmChars[0]) + (ddChars[1]?dd:"0"+ddChars[0]);
return datestring;
}
var date = new Date();
date.setDate(date.getDate() - 1);
yesterday = format_date(date);
Logger.log(yesterday);
Thanks!
Alex
function getDates(){
var MILLIS_PER_DAY = 1000 * 60 * 60 * 24;
var now = new Date();
var firstDay = new Date(now.getFullYear(), now.getMonth(), 1); // return first day of the month
var yesterday = new Date(now.getTime() - MILLIS_PER_DAY);
var timeZone = AdWordsApp.currentAccount().getTimeZone();
return Utilities.formatDate(firstDay, timeZone, 'yyyyMMdd') + ', ' + Utilities.formatDate(yesterday, timeZone, 'yyyyMMdd');
}
.getStatsFor();getStatsFor(firstDay, yesterday);var MILLIS_PER_DAY = 1000 * 60 * 60 * 24;
var now = new Date();
var firstDay = new Date(now.getFullYear(), now.getMonth(), 1); // return first day of the month
var yesterday = new Date(now.getTime() - MILLIS_PER_DAY);
var timeZone = AdWordsApp.currentAccount().getTimeZone();
var start = Utilities.formatDate(firstDay, timeZone, 'yyyyMMdd');
var end = Utilities.formatDate(yesterday, timeZone, 'yyyyMMdd');
var kws = AdWordsApp.keywords().withCondition("Impressions > 1").forDateRange(start,end).get();function getDates(){
var MILLIS_PER_DAY = 1000 * 60 * 60 * 24;
var now = new Date();
var firstDay = new Date(now.getFullYear(), now.getMonth(), 1); // return first day of the month
var yesterday = new Date(now.getTime() - MILLIS_PER_DAY);
var timeZone = AdWordsApp.currentAccount().getTimeZone();
start = Utilities.formatDate(firstDay, timeZone, 'yyyyMMdd');
end = Utilities.formatDate(yesterday, timeZone, 'yyyyMMdd');
return Utilities.formatDate(firstDay, timeZone, 'yyyyMMdd') + ', ' + Utilities.formatDate(yesterday, timeZone, 'yyyyMMdd');
}
getDates();