Reputation: 1837
I cannot figure out how to use the DateTime Maximum function with multiple data fields. I have 2 (DateTime) data fields that I want to get the maximum value.
The "values" field only lets you type a literal or drop in ONE field. How can I create an array of my 2 fields?
Thank you!
Upvotes: 0
Views: 1139
Reputation: 771
Ob
I think the problem you are having is that the input is not a date but an array of dates: DateTime[]
I don´t think this function is typically made to help you find the biggest between 2 dates in 2 datafields.
The way this function works is that you need to give it an array and of course the second param is a date.
To do so, you can use a smartobject that will return you a list of datetime (when you call the list, make sure you don´t return just the first, this is the default value).
The function will then work fine and tell you which of the dates in this list is the 'maximum'.
Now, if you really have to use the dates in those datafields, you will first need to convert those 2 datetime into an array of datetime. Unfortunately, I am not aware of a function able to do that (I may be wrong...).
I see 3 options nonetheless:
A simple version for #3 would be:
declare @D1 datetime
declare @D2 datetime
SET @D1 = getdate()
SET @D2 = getdate()+100
if (@D1>@D2)
select @D1
else
select @D2
I hope this helps.
Upvotes: 2