How do I assign the current date (not current datetime) as default value to a DateTime field

1
I need to assign the current date as a default value to an attribute with a DateTime data type, but without including the time element. Is this possible? It appears that Mendix will only allow [%CurrentDateTime%] to be set as the default values, and not any of the other date values, such as [%BeginOfCurrentDay%] which is what I really need.
asked
3 answers
1

You can't use [%BeginOfCurrentDay%] as a default value there, because the beginning of the current day depends on the timezone, while you can always determine [%CurrentDateTime%] independently of the timezone. Though now that I think about it, I don't see a reason why you shouldn't use the current session to determine this when creating an object. I suggest filing a feature request to get this option, though I may be missing something here which makes this impossible.

answered
0

You must use beginning of current day [%BeginOfCurrentDay%]. See this And make sure you set your domain model on localize no and always make sure you use UTC time to avoid localize problems.

Regards,

Ronald

answered
0

I have found an alternative approach. Instead of assigning a default value for the attribute, I have created an After Create event which runs a microflow which sets the attribute value to [%BeginOfCurrentDay%]. This seems to work fine, but I don't really see why it should not be possible to assign this as a default value. The localization issue would apply equally whether it's assigned as a default or in an After Create event.

answered