On Date Conversion

This forum allows users to post and respond to "How Do I Do ....." questions. The information contained in this forum has not been validated by K-Rise Systems and, as such, K-Rise Systems cannot guarantee the accuracy of the information.
Post Reply
Toyeyemi
Posts: 15
Joined: February 18th, 2022, 1:29 pm
Contact:

On Date Conversion

Unread post by Toyeyemi »

I have a method that I am building that takes in a date from a user as MM/DD/YYYY and then uses that date to query a JDE Table. In order to facilitate this I'm using the ToDate Data Conversion Service in order to change the date from a DisplayDate Format to a JDEDate Format.
Date_Conversion_Method.png
Date_Conversion_Method.png (103.35 KiB) Viewed 1250 times
Date_Conversion_Method.png
Date_Conversion_Method.png (103.35 KiB) Viewed 1250 times
The method above takes in the user's input, converts the dates to the necessary format, and then passes the information into the submethod where the query is run.

While using this method, I discovered that if the user refrains from putting in a date(meaning that the toDate service is given an empty string) the
toDate service defaults to returning the value for the current day.
Date_Conversion_Output.png
Date_Conversion_Output.png (83.93 KiB) Viewed 1250 times
Date_Conversion_Output.png
Date_Conversion_Output.png (83.93 KiB) Viewed 1250 times
Using this output would break my method as I the user would be looking for results without specified date information rather than information filtered to today's date. I've created a workaround wherein I check if the original date was empty or not before passing in the information from the ToDate service.
Data_Conversion_Workaround.png
Data_Conversion_Workaround.png (87.3 KiB) Viewed 1250 times
Data_Conversion_Workaround.png
Data_Conversion_Workaround.png (87.3 KiB) Viewed 1250 times
What I want to ask today is: Is the default return of the current day intentional? If so, is there another way of converting the date such that no default value would be given if no date was input?
word count: 276

Tags:
SteveCap
Posts: 329
Joined: August 26th, 2021, 9:18 am
Contact:

Re: On Date Conversion

Unread post by SteveCap »

ToDate is currently intentionally using the current date as the FromDate if nothing is passed in. You would need to do the check outside of the service.
word count: 27
CathyC
Posts: 472
Joined: November 16th, 2021, 11:15 am
Contact:

Re: On Date Conversion

Unread post by CathyC »

I think it should throw an exception instead when blank was given to convert.

Consider this scenario:
the user is given the option to select a requested date on their order. If they choose a date too soon to today, they incur an additional charge.
There is a service to convert the requested date to the correct JDEDate format to use in some context with JDE.
If the requested date is required, there is no problem, the ToDate service would always receive an input and work.
Though if for any reason it is no longer required, it will look like it works (no exception) but will be telling JDE the user chose today as the requested date and incur and additional charge.

I talked with some other developers on this, it is not intuitive that it defaults to today
word count: 139
JustinVanRegenmorter
Posts: 572
Joined: August 26th, 2021, 9:56 am
Contact:

Re: On Date Conversion

Unread post by JustinVanRegenmorter »

ToDate has been changed to require a date to be passed in.
word count: 12
Post Reply