Find number of days between system date and Offer date | Community
Skip to main content
akramullak35861
New Participant
April 15, 2020
Solved

Find number of days between system date and Offer date

  • April 15, 2020
  • 4 replies
  • 6586 views

In ACC WebApp I am trying to get the number of days between System date and Offer date with the below syntax but I dont get anything, even tried converting just to "%2M/%2D/%4Y" that also does not work when used with DaysDiff function. 

 

ctx.vars.OfferDate= formatDate(ctx.recipient.Offer_Date,"%2M/%2D/%4Y %02H:%02N:%02S");

ctx.vars.SysDate = formatDate(getCurrentDate(),"%2M/%2D/%4Y %02H:%02N:%02S")

ctx.vars.datediff = DaysDiff(ctx.vars.OfferDate, ctx.vars.SysDate )

 

Also tried javascript  syntax, this also does not work

ctx.vars.SysDt=ctx.vars.SysDate.getTime();

ctx.vars.OfferDt =ctx.vars.OfferDate.getTime(); 

ctx.vars.Time_Diff = ctx.vars.SysDt - ctx.vars.OfferDt;
ctx.vars.Date_Diff = ctx.vars.Time_Diff/(1000 * 3600 * 24);

 

 

 

 

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Jonathon_wodnicki

Hi,

 

The JS is:

 

new Date() - new Date(ctx.vars.OfferDate)

 

 

Be aware that you're comparing 2 clocks here- the one on the db server and the one on the app server.

A more consistent approach would be to do the math on the db: DaysAgo(@Offer_Date) or whichever resolution is desired.

 

Thanks,

-Jon

4 replies

Jonathon_wodnicki
Jonathon_wodnickiAccepted solution
New Participant
April 20, 2020

Hi,

 

The JS is:

 

new Date() - new Date(ctx.vars.OfferDate)

 

 

Be aware that you're comparing 2 clocks here- the one on the db server and the one on the app server.

A more consistent approach would be to do the math on the db: DaysAgo(@Offer_Date) or whichever resolution is desired.

 

Thanks,

-Jon

prasannakumarmarru
New Participant
April 18, 2020

Hi,

You should use GetDate() function  instead of getcurrentdate()

Thanks!

akramullak35861
New Participant
April 16, 2020
akramullak35861
New Participant
April 15, 2020

Can someone move this query to Adobe Campaign Classic please.