Populate table based on _createdDate.

I’m using the below code to populate a table but it’s not working:

export function datePicker1_change() {

	let searchString = $w("#datePicker1").value;
	$w("#dataset1").setFilter(wixData.filter()
	.eq("_createdDate", searchString));
}

Why? Anyone?

Thanx

I also have this :

export function datePicker1_change() {

$w("#dataset1").setFilter(wixData.filter()
	.eq("_createdDate", $w("#datePicker1").value));
}

HELP :frowning:

Did you refresh the table after filtering the dataset.
something like:

$w("#table").refresh();

Let me know if that did the trick.

Hi, Manny,

I think your problem is that you are trying to filter data using equals filter. _createdDate field represents exact time when item was created down to milliseconds. If you want to filter created items on that day which was set in DatePicker try something like this:

export function datePicker1_change(event, $w) {
	const value1 = $w("#datePicker1").value
	const value2 = value1
	value2.setDate(value1.getDate()+1)
	$w("#dataset1").setFilter(wixData.filter().between('_createdDate', value1, value2))
}

Thank you so much guys, I tried both of your solutions and I had no luck.
Omer Yaron , I tried refreshing the table on change and it didn’t do anything at all.
Gediminas Kriščeliūnas , I tried your approach but it was asking for semicolons at the end of every line so I added them to make the code work but it didn’t work. :frowning:

On load, I’m able to see my entire database in my table but when I filter it using the date picker it just throws everything blank. I’m sooooo confused here.

Sorry there was a mistake in my code snippet. Try it one more time with this:

export function datePicker1_change(event, $w) {
	const value1 = $w("#datePicker1").value;
	const value2 = new Date(value1.getTime());
	value2.setDate(value1.getDate()+1);
	$w("#dataset1").setFilter(wixData.filter().between('_createdDate', value1, value2));
}

Ok, so I just tried it again with the new code you just posted and still no luck. Man, ever since I started learning Wix Code I’ve had such bad luck with repeaters, I can never make them work with codes. :frowning:

Oh snap! Never mind, I was making a dumb mistake. LOL… Mr. Gediminas Kriščeliūnas , you sir are the man. Thank you so much.

Hi may insert my self here? How about filter by _owner?
filter my database according to it’s _owner ID? and the result will display on a repeater