Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
kunkumnaveen
Specialist
Specialist

How to convert the format of Date

Hello All,

I got two requirements to do 

1) To show dates in desc order (Which is done using below code)

Dual(

date($(varMaxDate) - Iterno()+1,'DD-MM-YY'),

if( date($(varMaxDate) - IterNo() + 1) =Date($(varMaxDate)),1,Peek("MainDate")+1))as "MainDate"

 

2)  I need to display Max Date and Min Date,hence in KPI I have written below expressions

        expression : Max(MainDate),Min(MainDate)

      Capture.PNG

Instead of getting Max Date and Min Date , I am getting numbers as shown above, this is because of  Daul function ,hence how I convert those numbers into date in UI 

 

Thanks

 

7 Replies
kunkumnaveen
Specialist
Specialist
Author

Is there any way to write a expression to get Max date and Min date in DD-MM-YY format

 

kunkumnaveen
Specialist
Specialist
Author

Hello All,

I am still looking for the suggestions on writing a expression which can get me max and

min dates in a KPI instead of numbers 

 

tresesco
MVP
MVP

Put formatting function date() around max/min, like:

Date(max(MainDate), 'DD-MM-YYYY')

kunkumnaveen
Specialist
Specialist
Author

Hi Tresesco,

Thanks for reply,

I tried using the same ,what I am getting is some thing strange , I suppose to get 30th july 2021 as max date but I am getting

Capture.PNG

 

tresesco
MVP
MVP

Your approach for date creation seems to be wrong. Date is dual field by default, i.e. - if you have a proper date, you don't need to create a dual value for this field explicitly. If you are doing so, that means your number values at the back of the date values are not real date values but some custom values that are just being used for sorting. With this approach you are complicating things unnecessarily. I

kunkumnaveen
Specialist
Specialist
Author

Yes you are right its seems same to me that I am complicating the things but the thing is I need dates to be shown in descending order in the front end ,hence I am assigning the values to dates using daul function 

 

Capture.PNG 

tresesco
MVP
MVP

I see your point. In visualization you can set your sort order, but for selection panel field sort order - it seems to be always 'ascending'. There should have been a setting for this sort order; and this is really imperative for date fields.

 

As a workaround, you can try putting negative weight to the date field and then use another negation for any calculation on top of it. 

Dual(-MainDate, MainDate) as MainDate

and then 

Date(max(-MainDate), 'DD-MM-YYYY')