RE: Best Method to obtain difference in days between two dates?
Answered
What is the best method to obtain the difference in days between a Date and a DateTime?
I have a Transaction Record (Work Order) with two fields:
InternalId: actualproductionenddate Type: date
InternalId: createddate Type: datetime
In Analytics Dataset I have tried to create a Formula Field using the following:
{actualproductionenddate}-CAST_TO_DATE({createddate})
The intention is to cast {createddate} of type datetime to a type date and subtract it from {actualproductionenddate}.
Ideally the result should generate the number of whole days between these dates.
Instead I am getting decimal values and I am unsure why.
Sample Data :
Date Create: 3/31/2021 4:29 pm
Actual Production End Date: 3/31/2021
Formula Result: -0.69
Best answer
I’ve just looked through some of my examples and I’ve used TRUNC() on the dates before subtracting.