cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
z_mike_90
Helper II
Helper II

Problem with Date Difference calculation

I have a scheduled flow that run once a day.  The flow action does a date difference calculation between the current date and a date field in CRM.  The problem is that the date is off by one day.  For example, when the current date is today (11/22/2022) and the CRM date is set to 11/24/2022, the date calculation result is that there is a 1 day difference instead of 2.  No matter what date I choose for the CRM date, the date is always one day off.

 

Schedule:

Recurrence.png

 

Date calculation (Integer type variable):

intervaldays.png

Formula:  

div(sub(outputs('Get_CRM_Date_Ticks'),outputs('Get_Current_Date_Ticks')),864000000000)
 
The formula to get the CRM Date:
int(ticks(items('Iterate_through_CRM_records')?['gbs_CRMdate']))
 
The formula to get the current date is 
int(ticks(utcNow()))
 
CRM Date field properties:
dateproperties.png
I'm scheduling this in the Central Time Zone.
1 ACCEPTED SOLUTION

Accepted Solutions
v-dezhili-msft
Microsoft
Microsoft

Hi @z_mike_90 ,

Are you trying to figure out the difference between two days?
Although you set the Date field in the table to only include time, ntcnow() still includes time, so their difference will be a float, so we should use formatDateTime() to exclude the time of utcnow().

vdezhilimsft_0-1669189412221.png

 

vdezhilimsft_1-1669189412222.pngthumbnail_image.png

Best Regards,

Dezhi

View solution in original post

1 REPLY 1
v-dezhili-msft
Microsoft
Microsoft

Hi @z_mike_90 ,

Are you trying to figure out the difference between two days?
Although you set the Date field in the table to only include time, ntcnow() still includes time, so their difference will be a float, so we should use formatDateTime() to exclude the time of utcnow().

vdezhilimsft_0-1669189412221.png

 

vdezhilimsft_1-1669189412222.pngthumbnail_image.png

Best Regards,

Dezhi

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (5,719)