Expand my Community achievements bar.

Adobe Campaign User Groups are live now. Join our Adobe Campaign User Groups and connect with your local leaders!

DaysDiff function with one date field?


Level 2


How can I calculate the days difference (using the daysdiff function) on one date field? Preferably for the most recent 3/4 dates in the field.

BACKGROUND: I need to know the days between each customers multiple journey dates for a campaign. Then work out the average of this number.

Many thanks,


3 Replies



Hi robertw937098

Date Difference could be calculated as: SELECT DATEDIFF(day, 'yyyy-mm-dd hh:mm:ss', 'yyyy-mm-dd hh:mm:ss');

PostgreSQL allows you a more accurate difference like (3 days, 10 hours) using the 'timestamp' option as below:

SELECT 'yyyy-mm-dd hh:mm:ss'::timestamp - 'yyyy-mm-dd hh:mm:ss'::timestamp;

'DATE_PART' prefixed to the above will again give difference in days.

SELECT DATE_PART ('day', 'yyyy-mm-dd hh:mm:ss'::timestamp - 'yyyy-mm-dd hh:mm:ss'::timestamp);

Hope that helps!


Level 2

Hi Garima,

Thanks for your reply.

Though I still have the same issue. My question is, how is it possible to do a DaysDiff(@OUT_DATE_DEP) function on all the data in one date field per recipient?

For instance, something like... DaysDiff(row1.@OUT_DATE_DEP,row2.@OUT_DATE_DEP)

E.g. The below customer has many out date dep dates.


Many Thanks,



Community Advisor

Hi Robert,

Difference can be found between two fields. But if you are going for difference between all the dates for one Recipient you won't get one output rather many rows. Can you please explain how you want your output to look like?