Can set the DE or entity attribute of date type 's format to 2022-03 or 202203?

I have an DE or attribute of date type ,but the context is only 2022-03, not 2022-03-01, no day part, how to define or format this date DE or entity attribute ?’

Thanks

Hi @linxd ,

There is currently not a data element type which supports only the year and month. I would suggest a couple of different approaches begining with the one which in my opinion would deliver the highest quality data.

  • Option sets Create two data elements consisting of “Year” and “Month”. Use an option set to create a list of years which you are interested in and assign that to the “Year” data element. I would keep it as short as possible, and not include future years until you need them (or unless they are applicable). Then create another option set to represent the month. I guess you could use Jan-Dec. In the data entry form, the user would need to select both the year and the month. I would suggest to create a validation rule which would require them to enter both if they have entered one or the other. I think this approach would likely result in the best quality data because users could only enter valid years and valid months through the options.

  • Numeric entry You could consider just allowing users to enter a non-zero number. Then you could create a validation rule to say that the Year must be greater than X and another rule to say that it must be less than Y. This of course would not prevent users from entering potentially incorrect years and months since there is no direct enforcement of the validation rules, but it might work if your users are well trained.

  • Use the date data element type: Just use the date type data element and instruct users to pick the first day of the month. If you only need the year and month, then you could just ignore the day which was selected.

  • Custom JS control Similarly, you could implement a custom control in your data entry form like this. The downside of this approach is that it would only work on the web.

  • Text data element Using text and trying to do any sort of analysis with it is almost never going to work. I would not using a free-text field for allowing users to enter 2022-03 or 202203 because inevitably they are going to make a mistake and you will have a lot of data which would not be able to be used.

Hope that helps and good luck!

Regards,
Jason

3 Likes

Thanks,Jason!

1 Like