Click here to Skip to main content
15,895,256 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I am running into an issue, I could not figure out the behavior of my code.

Below is my code.

What I have tried:

$scope.OnLoginChange = function (LoginChangeFilter, inputVal) {
                $scope.Values = $scope.allValues;
                debugger;
                console.log(LoginChangeFilter);
                console.log(inputVal);
              
                var newArray = [];
                switch (RmsLoginChangeFilter) {
                    case '=':
                        newArray = $scope.Values.filter(function (r) {
                            var d1 = new Date(r.Login.toString());
                            debugger;
                            console.log(d1);
                            var d2 = new Date(inputVal.toString());
                            console.log(d2);
                            console.log(d1 == d2);
                            cosole.log(d1>=d2);
                            console.log(d1<=d2);
                            if (d1 == d2) {
                                return r;
                            }
                        });
                        debugger;
                        break;
                    case '>=':
                        newArray = $scope.Values.filter(function (r) {
                            var d1 = new Date(r.Login.toString());
                            var d2 = new Date(inputVal.toString());
                            if (d1 >= d2) {
                                return r;
                            }
                        });
                        debugger;
                        break;
                    case '<=':
                        newArray = $scope.Values.filter(function (r) {
                            var d1 = new Date(r.Login.toString());
                            var d2 = new Date(inputVal.toString());
                            if (d1 <= d2) {
                                return r;
                            }
                        });
                      
                        break;
                    default:
                        newArray = $scope.Values
                        break;
                }

                $scope.Values = newArray;
            }
Posted
Updated 19-Jul-17 12:01pm

1 solution

I resolved it.

if (d1.getTime() === d2.getTime()){

// code

}
 
Share this answer
 
Comments
Graeme_Grant 16-Sep-17 8:08am    
Please don't answer your own question with a solution and then accept it as a valid solution. This is see as REP farming and can get you banned if continued. Update your question instead.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900