Forum Discussion
Custom columns with timestamps and date transformations
- 9 years ago
DanielV91 there are some superfluous checks in your code: if a condition is not true, then you don't need to check in the else part if the condition is false.
Assuming the data is correct, your code can be shortened to:
if [Resolved] <> null then [Resolved] else if [Closed] = null then [Opened] else Date.AddDays([Closed],-7)
Note: Date.AddDays can also be used with datetime type data, so no need to convert to date.
Hello,
First of all, 2017 is not a leap year ::smileyvery-happy: so 29 of February doesn't exist.
Second, make sure to properly format that date type; I suggest you only keep the date and get rid of the hours.
I managed to achive your requirement with the following query:
if [Resolved] <> null then [Resolved] else if [Resolved] = null and [Closed] = null then [Opened] else if [Closed] <> null then Date.AddDays([Closed],-7) else "Check Data!"
See the result in the following picture and let me know if this helped you
DanielV91 there are some superfluous checks in your code: if a condition is not true, then you don't need to check in the else part if the condition is false.
Assuming the data is correct, your code can be shortened to:
if [Resolved] <> null then [Resolved] else if [Closed] = null then [Opened] else Date.AddDays([Closed],-7)
Note: Date.AddDays can also be used with datetime type data, so no need to convert to date.
- DanielV919 years agoFrequent Visitor
MarcelBeug Thanks for noticing, I should have paid more attention, my bad.
- RohithGn9 years ago
Helper I
Thanks a ton MarcelBeug your code is working as expected
DanielV91 Thanks a lot for the reply :)