function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
si risi ri 

how to query standard Date/Time fields.

Hi all,
How to fetch records between StartDateTime and EndDateTime including StartDateTime and EndDateTime records by comparing with Activity date
StartDateTime : datatype( Date/Time)
EndDateTime   :datatype( Date/Time)
Activity date :datatype( Date/Time)


 My query:
List<Event> eventList = [select  WhatId, Subject, ActivityDate, StartDateTime, EndDateTime from Event where WhatId= :accountId and ActivityDate <= StartDateTime between  EndDateTime <= ActivityDate ];

Can anyone please help me with right query
Sainath VenkatSainath Venkat
@si ri,

Please try below query.
 
List<Event> eventList = [select  WhatId, Subject, ActivityDate, StartDateTime, EndDateTime from Event where WhatId= :accountId AND ActivityDate <= StartDateTime AND EndDateTime >= ActivityDate ];

Mark it as best, if it solves your issue.
si risi ri
Hi Sainath Venkat,
I have tried your query but it is not working.
 
Sainath VenkatSainath Venkat
try below code.
 
List<Event> eventList = [select  WhatId, Subject, ActivityDate, StartDateTime, EndDateTime from Event where WhatId= :accountId AND ActivityDate >= StartDateTime AND EndDateTime <= ActivityDate ];