+ Start a Discussion
Baz DensonBaz Denson 

formula to add time to date

I aa trying to use process builder to create an event at 9:15 on the same date as another event. my formula is

DATETIMEVALUE(TEXT(YEAR([Event].StartDateTime ))+"-"+TEXT(MONTH([Event].StartDateTime ))+"-"+TEXT(DAY([Event].StartDateTime ))+" 09:15:00")

but I get a syntax error.

Can anyone assist with debugging please?

 
Best Answer chosen by Baz Denson
Alain CabonAlain Cabon
@Baz Benson

DATEVALUE is needeed here ( YEAR(date) )

Always "Save" the formula every time because the last error message remains if not and you don't get the correct error message.
 
DATETIMEVALUE( TEXT ( YEAR ( DATEVALUE ( [Event].StartDateTime ) ) ) + '-' + TEXT ( MONTH ( DATEVALUE( [Event].StartDateTime ) ) ) + '-' + TEXT ( DAY ( DATEVALUE ( [Event].StartDateTime ) ) ) + ' 09:15:00' )

All Answers

Alain CabonAlain Cabon
@Baz Benson

DATEVALUE is needeed here ( YEAR(date) )

Always "Save" the formula every time because the last error message remains if not and you don't get the correct error message.
 
DATETIMEVALUE( TEXT ( YEAR ( DATEVALUE ( [Event].StartDateTime ) ) ) + '-' + TEXT ( MONTH ( DATEVALUE( [Event].StartDateTime ) ) ) + '-' + TEXT ( DAY ( DATEVALUE ( [Event].StartDateTime ) ) ) + ' 09:15:00' )
This was selected as the best answer
Baz DensonBaz Denson
When I use that formula I get 
The formula expression is invalid: Incorrect parameter type for operator '+'. Expected Text, received DateTime

 
Baz DensonBaz Denson
scratch that.. the error was related to a different formula
 
Alain CabonAlain Cabon
I had the same problem as long as I didn't save the formula. The error message seems refreshed each time you validate (without a save) but it is often the message of the previous error that remains (and it is not accurate anymore with the real formula in fact).
You would have get the tip of using DATEVALUE for YEAR as soon as you would have saved the formula by the process builder directly (we all have wasted time with this problem).