DateTime.MinValue is not properly formatted

Answered
Angie R asked on April 5, 2024

Hi,
I have an issue when trying to display a datetime having the DateTime.MinValue set.
The format that should be used is - dateTimePattern: "yyyy-MM-dd"- and I'm expected to have displayed: 0001-01-01, but 1-01-01 is displayed.
The data is retrieved from server side and the value that is received is : -62135596800000.
I've created a sample using static data and the behavior can be seen here:https://jsfiddle.net/kfn47hpe/
Please advice how this can be fixed.

7 answers

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster April 5, 2024

Hello, Angie!
 
Thank you for reaching out to us.
 
Kindly note that it is the expected result of formatting dates with years earlier than 1000 in Flexmonster.
Please provide us with more details about your use case so we can think about possible workarounds to achieve the desired behavior.
 
Hope it helps.
Feel free to contact us in case of any other questions.
 
Kind regards,
Solomiia 

Public
Angie R April 8, 2024

There are some items having null values in the database for datetimes. For these I set on server side DateTime.MinValue and expect to have displayed on client: 0001-01-01.

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster April 8, 2024

Hello, Angie!
 
Thank you for providing additional information about your use case.
 
Kindly note that in Flexmonster, it is only possible to set full year formatting without leading zeros.
For the described case, we can suggest a workaround using our localizations. To explain the approach briefly, if the null date values are sent to Flexmonster, it displays them with "Invalid date" caption. This caption can be changed using localization from "Invalid date" to "0001-01-01" on the client side as follows:

new Flexmonster({
report: {
    //report properties
},
global: {
    localization: {
      grid: {
        dateInvalidCaption: "0001-01-01"
      }
  }
}
});

We have prepared a JSFiddle to illustrate the idea: https://jsfiddle.net/flexmonster/54u7fsna/.
 
Hope you will find our answer helpful.
Feel free to reach out to us in case of any other questions.
 
Kind regards,
Solomiia

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster April 16, 2024

Hello, Angie!

Hope you are doing well.

Our team is wondering if you had some time to try the suggested solution to show the full year with leading zeros using localization. Could you please let us know if it was helpful?

Looking forward to hearing from you.

Kind regards,
Solomiia

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster April 23, 2024

Hello, Angie!
Hope you are having a great week.
Just checking in to ask if the suggested approach to show the full year with leading zeros using localization. works well for your case?
Looking forward to hearing your feedback.
Kind regards,
Solomiia

Public
Angie R June 7, 2024

Hi,  thanks for your help and sorry for the late answer. In the end we've decided to use for the items having null values in the database 1900-01-01 value.

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster June 10, 2024

Hi, Angie!

Thank you for getting back to us.

We are glad to hear everything works well now.

Feel free to reach out to us in case of any other questions.

Kind regards,
Solomiia

Please login or Register to Submit Answer