Return Date instead of DateTime when using AddDays() with Date
66
Views
4
Comments
New
Builtin & User functions

When using the AddDays() function on an object of type Date, it will return an object of type Date Time. I would expect it to return a Date here since that's what I was working with and AddDays() does not impact that (unlike AddHours(), AddMinutes()).

For example:
AddDays(CurrDate(), 1) 
Will return a Date Time, while I'm only trying to obtain tomorrow's date.

This is intentionally, you can still get the date by converting the date time to date.

I understand that I can convert it back to a date, but what would be the reason to return a date time here in the first place, if I may ask? 

To me, this kind of feels like you're adding two integers and get a decimal returned. Sure, you can cast it back to an integer, but it makes much more sense to just return an integer.

Well I think it is pretty clear, for example I have a book on August 11 at 12:00 and I want to move it 5 days forward, I add 5 days, and then I have a datetime August 12 at 12:00. You are only adding days, you are not removing hours and minutes.

Sure, in your example that makes perfect sense. However, I was talking about the situation where the input is a date, not a date time.

In my case, I start with 11 August, add a day, and end up with August 12 at 00:00. 

Following/expanding on your logic: when I start with a date and use AddDays(), I would expect OutSystems to only add days, not add hours and minutes.

-----------------------------------

AddDays(#2025-08-11 12:00:00#, 1) = #2025-08-12 12:00:00# // Your example. Makes sense.
AddDays(#2025-08-11#, 1) = #2025-08-12   // My example. Makes sense.
AddDays(#2025-08-11#, 1) = #2025-08-12 00:00:00 // Current OutSystems behavior. Makes no sense, in my opinion.