Solved Date Value

Status
Not open for further replies.

AndyK16

New Member
Hello all

My build matches a date from a data item and the inputs and searches in another object fot that date
the issue i have is sometimes that date might not be present so i have to match the nearest date to it

Example 10/03/2018 from data and when it checks another screen from that transaction it will search for the 10/03/2018 but this date might not be there and the transaction date instead of the 10/03/2018 couldbe the 13/03/2018

So i want to create a bit of logic that if my search checks for the 10/03/2018 but that date is not present and goes by it say for example 28/02/2018 it then needs to go back up that list and checks for the first date after the 10/03/2018
 

VJR

Well-Known Member
Make use of the DateDiff function to give the result in number of days between two dates.

Eg;
DateDiff(9, "1/4/2018", "1/6/2018")
Gives result as 2 since there is a difference of 2 days.
The interval 9 in the parameter is used to return the difference in Days. (5 is for Months))

DateDiff(9, "1/4/2018", "1/4/2018")
Gives result as 0 since both dates are equal.

DateDiff(9, "1/4/2018", "1/3/2018")
Gives result as -1

Unsure what other system you are using to get the list of dates. But you might have to get the other dates in a collection then find the difference using Datediff and store the result in the collection itself. Once you have the difference using the above Function then you can decide which one has the lowest difference.

If you have the difference as 0 then its a complete match, else the next lowest number. You can do a web search and use the same logic that is used to find out the minimum of N numbers. If for example you found 4 as the minimum number then the DateColumn next to 4 in that row of the collection is the next available closest date.
 

AndyK16

New Member
Make use of the DateDiff function to give the result in number of days between two dates.

Eg;
DateDiff(9, "1/4/2018", "1/6/2018")
Gives result as 2 since there is a difference of 2 days.
The interval 9 in the parameter is used to return the difference in Days. (5 is for Months))

DateDiff(9, "1/4/2018", "1/4/2018")
Gives result as 0 since both dates are equal.

DateDiff(9, "1/4/2018", "1/3/2018")
Gives result as -1

Unsure what other system you are using to get the list of dates. But you might have to get the other dates in a collection then find the difference using Datediff and store the result in the collection itself. Once you have the difference using the above Function then you can decide which one has the lowest difference.

If you have the difference as 0 then its a complete match, else the next lowest number. You can do a web search and use the same logic that is used to find out the minimum of N numbers. If for example you found 4 as the minimum number then the DateColumn next to 4 in that row of the collection is the next available closest date.
thank you for the update and reply
 
Status
Not open for further replies.
Top