Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2170
UltraMaskedEditor - formatted for time
posted

I am trying to use an UltraMaskedEditor for the entry of time. I would like the display to represent hh:mm AM but when saved to the database I want hhmma. I have tried various combinations but it appears that if setting the EditAs to Time that the date will always be included when saved to the database.

The closest I have come is setting the EditAs to "UseSpecifiedMask" and the InputMask to "{Time}" with the DataMode set a "Raw" and the DisplayMode set to "IncludeBoth". This will result in the dispay being as I wish but what is saved to the database is hhmmAM.

I tried another option with the EditAs to "UseSpecifiedMask" and the InputMask to "##:##&\m". With the DataMode set to "Raw" and DisplayMode set to "IncludeBoth" I get the desired display and data but the user can enter an invalid time.

Is there anyway to get what I am looking for?

Display time as 08:00 AM but saved as 0800a

Display time as 12:30 PM but saved as 1230p

Parents
  • 69832
    Verified Answer
    Offline posted

    rblanchard said:
    I have tried various combinations but it appears that if setting the EditAs to Time that the date will always be included when saved to the database.

    There is really no data type for a time without tha date, with the exception of TimeSpan, and that is not specifically designed for a time of day. It sounds like you want to persist the string representation of the time component of a date in the database...what you could do is derive from the control, add a property of type string and bind the data to that, and from that property, return the "hhmma" formatted string representation of the Value property. You could then set the EditAs property to 'Time', so that the mask enforces the proper input, but do what you want with the value.

Reply Children
No Data