Solved Dater ange

quest

New member
Local time
Today, 18:09
Joined
Nov 26, 2024
Messages
11
Hi
I have report with date field from which i get range with min and max. result is ok for example i get result 2017-2023. problem is that when a range is only one year i get result 2025-2025 for example. how do I get simple value like 2025 only instead of 2025-2025.
 
You may have to show us the expression or code you're using to produce the range. I imagine you'll need to add an IF statement or something similar to check the value for duplicate years.
 
You may have to show us the expression or code you're using to produce the range. I imagine you'll need to add an IF statement or something similar to check the value for duplicate years.
I use this expression =Min(DatePart("yyyy";[EnterDate])) & "-" & Max(DatePart("yyyy";[EnterDate]))
 
I use this expression =Min(DatePart("yyyy";[EnterDate])) & "-" & Max(DatePart("yyyy";[EnterDate]))
That doesn't look right if [EnterDate] is a query parameter, but you can try something like this:
Code:
IIf(Min(Year([EnterDate]))=Year(Max([EnterDate])),Year(Max([EnterDate])),Year(Min([EnterDate])) & "-" & Year(Max([EnterDate])))
 
You need to make the expression more complex or create a function. I would create a function. Then you could use the min and the max and compare them so you can decide what to return.
 
EnterDate is the name of field.
I updated the code above, because I missed to use the Year() function in the other areas. Give it a shot and let us know what happens.
 
Report is based on query. expression =Min(DatePart("yyyy";[EnterDate])) & "-" & Max(DatePart("yyyy";[EnterDate])) is written in the control source
 
I solved it. it shoul be like this IIf(Year(Min([EnterDate]))=Year(Max([EnterDate])),Year(Max([EnterDate])),Year(Min([EnterDate])) & "-" & Year(Max([EnterDate]))). need to switch year and min. thanks
 
I solved it. it shoul be like this IIf(Year(Min([EnterDate]))=Year(Max([EnterDate])),Year(Max([EnterDate])),Year(Min([EnterDate])) & "-" & Year(Max([EnterDate]))). need to switch year and min. thanks
Sorry about that but glad to hear you got it sorted out.
 

Users who are viewing this thread

Back
Top Bottom