Skip to main content
Level 6
January 25, 2024
해결됨

DaysDiff function not giving correct result

  • January 25, 2024
  • 4 답변들
  • 855 조회

Hi, we have an option variable called lastExportDate and a field called lastModified. When we are trying to find the difference between two values using DaysDiff, we are not getting any result. Can somebody please help out with the Javascript code and the expression to use in additional data?

이 주제는 답변이 닫혔습니다.
최고의 답변: ParthaSarathy

Hi @sanjana12 ,

Considering your option's Data type is 'Date+time'

In workflow, fetch the option value and store it in variable as below,

 

vars.lastExportDate=getOption('lastExportDate');

 

In Query additional data or in enrichment, add the below expression to fetch the Days difference,

 

DaysDiff(ToDateTime($(vars/@lastExportDate)),@lastModified )

 

4 답변

isahore
Community Advisor
Community Advisor
January 25, 2024

Hi @sanjana12,

 

Check that both the fields you are comparing are of the date or datetime data type. If not, the function might not give you correct results or no results at all.

 

BR,

Ishan

ParthaSarathy
Community Advisor
Community Advisor
January 25, 2024

Hi @sanjana12 ,

Considering your option's Data type is 'Date+time'

In workflow, fetch the option value and store it in variable as below,

 

vars.lastExportDate=getOption('lastExportDate');

 

In Query additional data or in enrichment, add the below expression to fetch the Days difference,

 

DaysDiff(ToDateTime($(vars/@lastExportDate)),@lastModified )

 

~  ParthaSarathy S~  Click here to join ADOBE CAMPAIGN USER GROUP for Quarterly In-person | Hybrid | Virtual Meetups
Sanjana12작성자
Level 6
January 25, 2024

Is it possible to hardcode the values instead of fetching the option variable value.If so, how to do it?

AkshayAnand
Community Advisor
Community Advisor
January 29, 2024

Hi @sanjana12 

 

Yes you can also hard code the value as :

DaysDiff(ToDateTime('29/02/2024'),@lastModified )

I would suggest you could keep the code dynamic with @parthasarathy suggested code.

 

Thanks

Akshay