function markSocialPromotionsAsRead() {
var threads = GmailApp.search('category:social OR category:promotions is:unread older_than:7d newer_than:90d');
var now = new Date();
var oneWeekAgo = new Date(now.getTime() - 7 * 24 * 60 * 60 * 1000);
var threeMonthsAgo = new Date(now.getTime() - 90 * 24 * 60 * 60 * 1000);
for (var i = 0; i < threads.length; i++) {
var thread = threads[i];
var lastMessageDate = thread.getLastMessageDate();
if (lastMessageDate.getTime() >= oneWeekAgo.getTime() && lastMessageDate.getTime() < threeMonthsAgo.getTime()) {
thread.markRead();
}
}
}