We have to separate fields to pick appointment date & appointment time in Custom object. Now we have to filter out appointments between two dates (w/ time), so I need to compare appointment date & time both. For that, I am thinking to create a Formula field which takes both appointment date & time & provide appointment date & time in date/time type. Please provide formula to do so

  • what you have tried so far? Aug 16, 2018 at 9:37

3 Answers 3


You can handle this in Apex like this:

DateTime dt = DateTime.newInstance(myDate, myTime);
  • Awesome, just what I needed- simple and clean. Thank you!
    – Navigatrix
    Apr 9, 2020 at 15:28
  • OP asked for a formula Jul 15, 2020 at 14:49

DATETIMEVALUE(TEXT( App_Date__c )+ " "+ TEXT( App_Time__c ))+x/24

Note: X incidate time Zone difference (Kindly check user setting to know the Time Zone that has been mapped Name-> My Settings -> Language & Time Zone)


I have tried formula field using below,

DATETIMEVALUE(TEXT(Appointment_Date__c) + " " + LEFT(TEXT(Appointment_Time__c), 8)) + 7/24

But since it will not work only for daylight saving period (GMT-7), but not for standard timezone (GMT-8). So formula field doesn't work for such timezones.

For such timezones, we have the only option of Apex, so I created trigger & it worked.

trigger UpdateAppointemntDateTime on Ride__c  (before insert,before update) {
    for(Object__c r : trigger.new)
        if(r.Appointment_Date__c != null && r.Appointment_Time__c != null){

            String timeString =  String.valueOf(r.Appointment_Time__c);

            r.Appointment_Date_with_Time__c = DateTime.newInstance(r.Appointment_Date__c, 
                                            0, 0));


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .