> data=[{date:'22-12-2014',name:'selva'},{date:'10-10-2010',name:'raja'},{date:'
11-11- 2011',name:'suresh'}]
[ { date: '22-12-2014', name: 'selva' },
{ date: '10-10-2010', name: 'raja' },
{ date: '11-11- 2011', name: 'suresh' } ]
> var filteredData = []
> function parseDate(date){
... var date = date.split('-');
... var day = date[0]
... var month = date[1] - 1
... var year = date[2];
... return new Date(year, month, day)
... }
> for(var index in data){
... var obj = data[index];
... var date = parseDate(obj.date);
... if(date > new Date(2011, 0, 1))
... filteredData.push(obj)
... }
> filteredData
[ { date: '22-12-2014', name: 'selva' },
{ date: '11-11- 2011', name: 'suresh' } ]
Search thousands of free JavaScript snippets that you can quickly copy and paste into your web pages. Get free JavaScript tutorials, references, code, menus, calendars, popup windows, games, and much more.
Subscribe to:
Post Comments (Atom)
The Weekender: Moon metaphors, procrastinating monks, and a visit to a cheese factory
What we’re reading, watching, and listening to this week ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ...
-
code.gs // 1. Enter sheet name where data is to be written below var SHEET_NAME = "Sheet1" ; // 2. Run > setup // // 3....
No comments:
Post a Comment