Wish No DateUtils.SubtractPeriod method

Peter Simpson

Expert
Licensed User
Longtime User
Hello Anywhere Software,
I believe that today might be the first time that I've ever used DateUtils, I'm using the TicksToUnixTime method for ECWID API integration into a database.

I've noticed that DateUtils has DateUtils.AddPeriod but it does not have DateUtils.SubtractPeriod.

Would it be possible to add DateUtils.SubtractPeriod?

I do not need the method, I just noticed it was not there whilst looking through the list of methods.



Thank you...
 
Last edited:

Peter Simpson

Expert
Licensed User
Longtime User
I have to ask: can't we add a negative period to achieve the same thing?

Probably, I just noticed that there was an add but no subtract method. I don't need either, I just noticed that there was no opposite wording. I personally would just do something like this, DateTime.Date(DateTime.Now - (14 * DateTime.TicksPerDay)) for example to take 14 days off from today's date (or from any date of my choosing), but that's just me.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
DateTime.Date(DateTime.Now - (14 * DateTime.TicksPerDay)) for example to take 14 days off from today's date (or from any date of my choosing), but that's just me.
You will get the wrong* result when the DST changes.
Wrong = not what you expect.

A Period object can hold negative values so there is really no need to add another method.
 
Top