My Scenario is, I am having two fields as Startdatetime_c(date/time) & LastDatetime(date/time). Here another one field Nextdatetime_c(date/time Formula field) i want the Date from LastDatetime_c(date/time) and time from Startdatetime_c(date/time).I tried the following:

DATEVALUE(LastDatetime__c) & TIMEVALUE(Startdatetime__c)

But it throws the error as Error:

Unknown function TIMEVALUE. Check spelling.

How to resolve this?

  • Check this. Seemslike TIMEVALUE is still not available. Also how you are going to generate the datetime field here?
    – highfive
    Mar 20, 2014 at 8:35

2 Answers 2


Unfortunately there are no standard functions for that. You will have to build the datetime value from separate strings like this:

DATETIMEVALUE(TEXT(DATEVALUE(LastDatetime_c))&" "&MID(TEXT(Startdatetime_c),12,8))

  • Thanks for your comment @guy, i try your logic inside the formula editor but it throws the error as "YEAR()'. Expected Date, received DateTime" because am using Date/Time datatype for Formula field.. Mar 20, 2014 at 13:58
  • You are right. I tested this with a date field. I updated my answer accordingly. Actually it becomes better, since TEXT(DATEVALUE()) returns the date in the correct format for DATETIMEVALUE() Mar 20, 2014 at 14:26
  • Thanks for your support @guy "DATETIMEVALUE(TEXT(DATEVALUE(LastDatetime_c))&" "&MID(TEXT(Startdatetime_c),12,8))" this part works perfectly.. Mar 20, 2014 at 15:12
  • Hi @guy one help in this formula logic Days__c(Text) Formula: DATETIMEVALUE(TEXT(DATEVALUE(LastDatetime_c)+Days__c)&" "&MID(TEXT(Startdatetime_c),12,8)) INputs : Startdatetime_c = 20/03/2014 10:00 ,LastDatetime_c = 27/03/2014 10:00 Days__c = 8 Result : Nextdatetime_c = 04/03/2014 11:00 (Here time increased as 1 hour) User timezone & Organization timezones are same GMT+00:00 Europe/London If the month is move from MAR to APR then the hour will be increased, if the month is in MAR means the time should be perfect.. Mar 27, 2014 at 11:51
DateTime dt = DateTime.newInstance(LastDatetime__c.year(), LastDatetime__c.month(), LastDatetime__c.day(), Startdatetime__c.hour(), Startdatetime__c.minute(), Startdatetime__c.second());

Have a look in the docs at datetime methods

  • Thanks for your comment @Richard here i need a Formula logic for the above question, not as apex code.Am implementing formula field logic.Is there any other ways to implement inside the Formula Editor? Mar 20, 2014 at 13:52

You must log in to answer this question.

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