I think you are thinking of the right solution. I will list the options.
Imagining that you would need calculations, the best solution is not to do this. The correct one would be a way to normalize the value. For example, if you choose decimal notation, then record 0.25 to 15min or 5 to 5h.
If it is not possible to normalize properly and really need to know when decimal or in time, then the solution is to have two distinct fields and an auxiliary indicating which of the two to use. Eventually I wouldn’t need this auxiliary field if I could work with null, so anything that’s not used would be null. Evidently the application (or a restriction in the database) would have to take care to never have both used.
If this cannot be done, any solution will be bad.
- However, if the field is merely descriptive and it matters little to the application what is inside it, then use a string may be the most appropriate.
The select button can be a good one. Depending on the option would prevent the completion of the other or even change the unique field shown to the user. You can change the mask. Might not even need this.
It is possible for the client application to identify that one was typed and prevent the other’s typing. You have to inform the user well that to release the other, if he wants, you have to delete one of these fields. I’m not saying it’s the best solution for your users.
I can’t tell you about the mask because I don’t know what can and can’t. Anyway I think this is already another question with a different problem (do it separately).
great options @bigown, I will see with the customer more in depth about the function of this field so that I can choose better, but I think the string type will supply well together with a show/Hide of the field that the user choose.
– Raylan Soares
In case I need to do calculations, I could normalize to decimal and have an auxiliary field to tell how the value should behave, right?
– Raylan Soares
If normalize would not need, because then time passes to be recorded as if it were a decimal value. It makes no difference if the user entered in hours or with decimals, it saves decimals and period. As you will present is application problem at each time, can present both in decimal and in time (have to do the conversion obviously)
– Maniero