This topic contains 5 replies, has 0 voices, and was last updated by sprintz 8 years, 3 months ago.
-
AuthorPosts
-
June 6, 2016 at 12:27 pm #5232
northern_brewerI am trying to determine how many days have elapsed since an order was placed.
I am using a Formula (numeric) field to do the calculation, and setting the formula to this: {today}-{trandate}
I expected to get a nice round integer, like 3, but instead I get 3.55820601851851851851851851851851851852
I can clearly round my results down to solve the problem. Is that the cleanest way to solve the problem? I’m looking for a durable solution that would solve for daylight savings time changes, etc.
This is a cached copy. Click here to see the original post. -
June 6, 2016 at 6:33 pm #5233
k_duncYou can always use the “Formula (Currency)” instead of “Formula (Numeric)”. This will return the value by default to two decimal places. Alternatively, try the “ROUND()” function in your formula.
-
June 7, 2016 at 10:16 am #5234
northern_brewerYes, I’ve decided to use CEIL({trandate}-{today}) in my search for now. I’m still wondering what the fractional part of the decimal number represents. I’m concerned my search could provide unexpected results at different times of day, in different time zones, before/after daylight savings time, etc.
-
June 7, 2016 at 10:47 am #5235
girieshgWhat’s the end goal here? If it’s just to see how many days elapsed on open orders, there’s a “Days Open” filter / column available by default. If you want the age of the order in days, use the function “Age in Days” on the Date field.
-
June 14, 2016 at 2:52 pm #5236
DewJust FYI, {today} includes a factor for the time of day (so at noon it would essentially have a “.5” at the end). You can use the TRUNC function to reduce this to a “day only” value like so: TRUNC ( {today} )
-
August 8, 2016 at 9:13 am #5237
sprintzOriginally posted by Dew
View Post
Just FYI, {today} includes a factor for the time of day (so at noon it would essentially have a “.5” at the end). You can use the TRUNC function to reduce this to a “day only” value like so: TRUNC ( {today} )
To expand on Dew’s comment, simply modifying your original formula(numeric) result will yield the result you are after
TRUNC({today})-TRUNC({trandate})
This will strip the time portion of the dateTime object and give you nice whole numbers.
-
AuthorPosts
You must be logged in to reply to this topic.