I have an application in which I need to be able to handle partial dates.
That is a partial dates like 09-2005 where 09 is the month and 2005 is the year.
Ideally there would be an ability to configure a control to understand that _ _-09-2005 = 01-09-2005 (dd-mm-yyyy) , but not display the 01 for the day. equally _ _- _ _ - 2005 would become 01-01-2005 with a flag set to 1 to indicate that only the year part is valid
I am intending to store the date in a date column with a data validity column 1 = Year, 2 = Year and Month and 3= Year, Month and Day
Any suggestions as to the best way to handle this or do's and dont's would be grealy apprecaited.
Thank you
The DateTImeEditor can't handle this because it deals with dates, which require an explicitly defined day month and year.
You can probably do this using an UltraMaskedEditor control with a regular numeric mask like "nn-nnnn", and then when it comes time to get a date out of the string value entered by the user, parse the text with a "01" inserted between the month and year, so that the value can be parsed as if it were a date.
Iam wondering if there has been any update to this
I have the following code
Dim ude As New UltraDateTimeEditor With orow If .IsDataRow Then If .Cells.Exists("Date Type") Then Select Case .Cells("Date Type").Text Case "Full Date" If .Cells.Exists("Date") Then With ude '.ButtonStyle = UIElementButtonStyle.Button3D '.DropDownStyle = DropDownStyle.DropDown '.DisplayStyle = EmbeddableElementDisplayStyle.Office2013 .FormatString = "dd-mm-yyyy" .MaskInput = "dd-mm-yyyy" .Nullable = True '.NullText = "[No Date Selected]" .SpinButtonDisplayStyle = Infragistics.Win.ButtonDisplayStyle.Always ' .Value = Today.Date End With End If Case "Month and Year" If .Cells.Exists("Date") Then With ude .FormatString = "mm-yyyy" .MaskInput = "mm-yyyy" ' .Nullable = True ' .NullText = "[No Date Selected]" .SpinButtonDisplayStyle = Infragistics.Win.ButtonDisplayStyle.Always ' .Value = Today.Date End With End If Case "Year Only" If .Cells.Exists("Date") Then With ude ' .ButtonStyle = UIElementButtonStyle.Button3D ' .DropDownStyle = DropDownStyle.DropDown ' .DisplayStyle = EmbeddableElementDisplayStyle.Office2013 .FormatString = "yyyy" .MaskInput = "yyyy" ' .Nullable = True ' .NullText = "[No Date Selected]" .SpinButtonDisplayStyle = Infragistics.Win.ButtonDisplayStyle.Always ' .Value = Today.Date End With End If
and it almost works but Month and Year while okay when editttng are set back to 00-2019 after edit
and .FormatString = "yyyy" is okay on format but .MaskInput = "yyyy" does not allow just the yyyy but will sort of work with mm-yyyy as masinput to disply yyyy
So close and yet so far.... Thank you in advance for any feedback
Hi,
What version of the controls are you currently using?
I know we made some changes to help support month+year. We did that as part of support for Japanese dates that include the Era. So it might work better now in the latest release. But I can't swear to it, because as I said, it was only done for JP dates.
If you can post a small sample project that I can run and debug, I would be happy to take a look at it and see if I can make it work for Month+Year. Or at least confirm that it can't be done.
I don't think Year-Only will work. But if you are just entering a year and nothing else, you a probably better off going with Brian's suggestion and just storing an integer value and using a mask or MinValue/MaxValue to limit the range. If it's just a year, there's really no reason to even store that as a DateTime. And most applications that deal with years will just show a dropdown with a list of years.