Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

I want to filter the below json data by start date and end date, it should return the data between start date and end date,

<html>
    <head>
        <title>Test</title>

    </head>

    <body>

        <script type="text/javascript">
            var product_data = [
                {
                    "productId": "12",
                    "productName": "ProductA",
                    "productPrice": "1562",
                    "ProductDateCreated": "2015-07-24T12:58:17.430Z",
                    "TotalProduct": 294
                },
                {
                    "productId": "13",
                    "productName": "ProductB",
                    "productPrice": "8545",
                    "TotalProduct": 294,
                    "ProductHits": {
                        "2015-08-01T00:00:00Z"
                    }
                },
                {
                    "productId": "14",
                    "productName": "ProductC",
                    "productPrice": "8654",
                    "TotalProduct": 78,
                    "ProductHits": {
                        "2015-08-10T00:00:00Z"
                    }
                },
                {
                    "productId": "15",
                    "productName": "ProductD",
                    "productPrice": "87456",
                    "TotalProduct": 878,
                    "ProductHits": {
                        "2015-05-12T00:00:00Z"
                    }
                }
            ];

            var startDate = "2015-08-04";
            var endDate = "2015-08-12";

            var resultProductData = product_data.filter(
                    function (a)
                    {
                        return (a.ProductHits) > startDate && (a.ProductHits) < endDate;
                    });
            console.log(resultProductData);
        </script>

    </body>
</html>
Comment

PREVIOUS NEXT
Code Example
Javascript :: calculate percentage in javascript 
Javascript :: how to use session with cookie js nodejs 
Javascript :: check if function exists 
Javascript :: react extends component App.defaultProps 
Javascript :: removes all item occurrences in array 
Javascript :: JSON: remember you can use a value that comes later 
Javascript :: prevent form submit twice jquery 
Javascript :: freecodecamp using props to render conditionally 
Javascript :: react with routing parameter and active NavLink 
Javascript :: validar fecha jquery 
Javascript :: angular auth guard @medium 
Javascript :: find result using type: mongoose.Schema.ObjectId, 
Javascript :: refreshapex 
Javascript :: prisma multiple queries in one query 
Javascript :: knex js how to group by many items 
Javascript :: pusher js 
Javascript :: regex remove whitespace 
Javascript :: how to use script tag in javascript 
Javascript :: js notimplemented error 
Javascript :: Include Path reactjs in VS code in in urud 
Javascript :: nested object 
Javascript :: javascript detect video change to muted 
Javascript :: how to get specific property name with numbers from object in javascript 
Javascript :: findOneAndUpdate many fields 
Javascript :: button onclick link to another page react 
Javascript :: submit form on ctrl enter 
Javascript :: user key value within the obj js 
Javascript :: laravel , json Why it shows Cannot access offset of type string on string error 
Javascript :: getting json from response using getSync method 
Javascript :: Getting PointerEvent instead of jQuery.Event on ng-click in AngularJS 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =