Skip to main content
10 events
when toggle format what by license comment
May 30, 2021 at 16:18 comment added sfdcfox @NickKahn Nothing. Just use DateTime.now().addDays(-1), and bind it directly, as in my answer.
May 30, 2021 at 16:16 comment added Nick yes you're right I'm thinking more towards using the apex rather than soql, so if I go with apex route what would add or change the logic?
May 30, 2021 at 16:14 comment added sfdcfox @NickKahn Ah, that makes sense. I forgot about that. Still, that's why I'd use Apex and just add -24 hours/-1 day, it makes it time zone agnostic.
May 30, 2021 at 15:51 comment added Nick I add convertTimeZone otherwise it was not catching the right number of hours. HOUR_IN_DAY(convertTimezone(My_Date__c))
May 30, 2021 at 15:49 vote accept Nick
May 30, 2021 at 3:54 comment added sfdcfox @NickKahn SOQL is strictly FIELD = VALUE. I see my previous comment had a typo or three. Try: (My_Date__c = TODAY AND HOUR_IN_DAY(My_Date__c)<17) OR (My_Date__c = YESTERDAY AND HOUR_IN_DAY(My_Date__c)>=17)
May 30, 2021 at 3:44 comment added Nick Unexpected token '<'. here is what i got SELECT My_Date__c FROM Employee__c WHERE My_Date__c = (TODAY AND HOUR_IN_DAY(My_Date__c)<17) OR (YESTERDAY AND HOUR_IN_DAY(My_Date__c)>=17)
May 30, 2021 at 3:32 comment added sfdcfox @NickKahn now() returns the current time, accurate to the millisecond. Adding -1 days will take you to exactly 24 hours ago. The second one, we're looking for everything "today" and everything "yesterday" after 5pm. If you also need to check for today up to 5pm, it'd be: (TODAY AND HOUR_IN_DAY(My_Date__c)<17) OR (YESTERDAY AND HOUR_IN_DAY(My_Date__c)>=17)
May 30, 2021 at 3:28 comment added Nick the first query, i'm not sure this will work because I'm looking for a specific time like 5pm the second query looks promising but one question where are you checking to see if the my_date is within past 24 hours (> yesterday at 5pm and <= today at 5pm) ?
May 30, 2021 at 3:15 history answered sfdcfox CC BY-SA 4.0