• RAHUL CHOUDHARY 11
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
Hi friends,

I have a custome object in which I am saving records and their is a field with name Date_and_Time__c which is containing time and date for next schedule. I need a query which will give all records during current time and next 5 mints.  For example if current time is 4:30 PM and I have given time 4:32 PM in Date_and_Time__c field then it should return this record and if their is any other records during this interval then it sould give all records.
My code is as below:
*****************
global static string GetReminder(){  
        
        DateTime dt = datetime.now();
        DateTime dtIST = dt.addMinutes(330); //330 is GMT +5:30 as IST conversion
        //String CurrentdateTime = dt.format('yyyy-MM-dd\'T\'hh:mm:ss\'Z\'');
        DateTime dt1 = dtIST.addMinutes(5); // 5 minutes after current time.
        
        List<SetReminder__c> reminderList = [Select Id, Name, Date_and_Time__c, Next_Best_Action__c, Recom_External_Id__c, Recommendation__c from SetReminder__c where (Date_and_Time__c >=: dtIST and Date_and_Time__c <=:dt1)];
      
        system.debug('DT:' + dtIST);
        system.debug('DT1:' +dt1);
        system.debug('ReminderList:' +reminderList);
         return null;
        }
   
Thanks in  advance
Regards:
Rajan   
  • September 19, 2017
  • Like
  • 0