I am trying to filter items in the Dataset with a user input date range.
I have written the following code:
$w.onReady(function () { const mymember = wixUsers.currentUser; const newDate = new Date() if (!mymember.loggedIn) { $w("#mymemberEmail").text = 'You must Log in!' } if(mymember.loggedIn === true) { mymember.getEmail() .then ((mymemberEmail) => { $w("#mymemberEmail").text = mymemberEmail console.log(mymemberEmail) $w("#datePicker2").value = new Date(newDate.getFullYear(), newDate.getMonth(), 1) $w("#datePicker3").value = new Date(newDate.getFullYear(), newDate.getMonth() + 1, 1) FilterDataSet(mymemberEmail) }) } }) export function FilterDataSet(mymemberEmail) { let date1 = new Date console.log(date1) let yearValue2 = $w('#datePicker2').value.getFullYear(); let monthValue2 = $w('#datePicker2').value.getMonth(); let dayValue2 = $w('#datePicker2').value.getDate(); let date2 = new Date(yearValue2,monthValue2,dayValue2,0,0,0); console.log(date2) let yearValue3 = $w('#datePicker3').value.getFullYear(); let monthValue3 = $w('#datePicker3').value.getMonth(); let dayValue3 = $w('#datePicker3').value.getDate(); let date3 = new Date(yearValue3,monthValue3,dayValue3,0,0,0); console.log(date3) $w("#datePicker2").onChange(() => $w("#dataset2").refresh) $w("#datePicker3").onChange(() => $w("#dataset2").refresh) $w("#dataset2").setFilter( wixData.filter().eq("email", mymemberEmail) .and(wixData.filter().ge("dateField", date2) .and(wixData.filter().ge("dateField", date3)))) $w("#dataset2").setSort( wixData.sort().descending("dateField")) }
When I look at the console.log, this is what date2 and date 3 formats look like:
But, when I look how the prior developer is storing the dateField in Content Manager, it looks like this.
How can I get the elements of date1 and date2 to test against this type of date format?
Thank you for your assistance.