Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
sieed
Helper II
Helper II

Calculate number of days ignoring AM and PM

I am trying to calculate date difference between today - some column of date in my table. I created a calculated column to accompish this. However, the result I got is in the date/time format. So I went ahead and changed the data type to whole number. Now, I see that if the number of days are different for the same date. If the time is in AM, then number of days is let's say X. Else if it's PM, then it's X-1. How do I fix this ? 

 

ampm.PNG

 

As you can see from this table, the last row should be 12 as well since it's the same date. But since it's PM, the date is reduced by one.. not sure why. 

 

1 ACCEPTED SOLUTION
dedelman_clng
Community Champion
Community Champion

On 'Jobs (2)'[Date] add the extra modifier .[Date].  This should strip the time off of it and give you what you want.

 

NumDays = TODAY() - 'Jobs (2)'[date].[Date]

 

I did this in one of my reports and it worked correctly. (current time is 10:53 AM)

 

Created Dt                          NumDays        NumDaysWithNoDateModifier

7/23/2015 12:45:28 PM      599                 598

9/1/2015 8:27:37 AM          559                 559

 

Hope this helps

David

View solution in original post

1 REPLY 1
dedelman_clng
Community Champion
Community Champion

On 'Jobs (2)'[Date] add the extra modifier .[Date].  This should strip the time off of it and give you what you want.

 

NumDays = TODAY() - 'Jobs (2)'[date].[Date]

 

I did this in one of my reports and it worked correctly. (current time is 10:53 AM)

 

Created Dt                          NumDays        NumDaysWithNoDateModifier

7/23/2015 12:45:28 PM      599                 598

9/1/2015 8:27:37 AM          559                 559

 

Hope this helps

David

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.