1

I have a workflow rule in place that needs to update a date field when another date field is is filled.

IF Date1 is filled, assign Date1 value to Date2.

What's the best formula to use in my Workflow action?

ETA: My 2 date fields have different data types. Date1 is Date and Date2 is Date/Time. I want to keep both data types as they are. Is there an enhanced formula that can convert 1 field to be compatible to the other and allow the update?

2

From the help docs:

Converting Between Date/Time and Date
Date and Date/Time aren’t interchangeable data types, so when you want to perform operations between Date and Date/Time values, you need to convert the values so they are both the same type. Some functions (such as YEAR(), MONTH(), and DAY()) also only work on Date values, so Date/Time values must be converted first.
Use the DATEVALUE( date/time ) function to return the Date value of a Date/Time. For example, to get the year from a Date/Time, use YEAR( DATEVALUE( date/time ) ) ).
You can convert a Date value to a Date/Time using the DATETIMEVALUE( date ) function. The time will be set to 12:00 a.m. in Greenwich Mean Time (GMT), and then converted to the time zone of the user viewing the record when it’s displayed. For a user located in San Francisco, DATETIMEVALUE( TODAY() ) returns 5:00 p.m. on the previous day (during Daylight Saving Time) rather than 12:00 a.m. of the current day. See A Note About Date/Time and Time Zones for more information.

I bolded the 2 you would need to use.

1

In this case the action is a field update. First choose the object and the Date2 field to update. The field update would "Use formula to set new value" radio button. The formula value would just be the API name of that field. If you just click on the Show Formula Editor link and insert the Date1 field you should be all set.

EDIT: Based on your comments, you will need to convert your date field to datetime. Here are the formula instructions from the documentation:

You can convert a Date value to a Date/Time using the DATETIMEVALUE( date ) function. The time will be set to 12:00 a.m. in Greenwich Mean Time (GMT), and then converted to the time zone of the user viewing the record when it’s displayed. For a user located in San Francisco, DATETIMEVALUE( TODAY() ) returns 5:00 p.m. on the previous day (during Daylight Saving Time) rather than 12:00 a.m. of the current day. See A Note About Date/Time and Time Zones for more information.

More information can be found in the documentation here: https://help.salesforce.com/HTViewHelpDoc?id=formula_using_date_datetime.htm

2
  • I tried that the first time but I ran into a syntax error. Now that I read it properly, it seems both my date fields are of different types. Error: Formula result is data type (Date), incompatible with expected data type (Date/Time). I have to keep both date types as they are. How do I enhance the formula to convert one date field to be compatible to the other? Thanks for your quick response @greenstork – Hazel Nov 11 '14 at 21:22
  • I've edited my response to explain how to convert a date to datetime. – greenstork Nov 12 '14 at 0:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.