Collapse strip based on date in database

For a dynamic events page, which has a strip with an Eventbrite ‘add-in’ on it, I need to collapse the strip based on the date of the event showing.

If the date of the event (dateDate) is before the current date, the strip (columnStrip7) needs to be collapsed. If the date of the event is after the current date, it may be expanded.

I’m still brushing up my Java, but haven’t been able to get this to work yet and couldn’t find other examples in the forum. Could anyone help?


OR! If it would be possible to get the HTML-code from the database, that would be even better.

Hey,

Please check out the following Stack Overflow question, regarding comparing 2 Javascript date objects:

Good Luck,
Itai

I have a simulair issue. I want to show only the new items in a gallery according a formula and the date in the database. Used field in database is _updatedDate, checked all codes multiple times, but no results yet.
Two other fields are also filtered and are working with a simulair procedure (used .contains there), so I think that there is something wrong with the date-field in the database?? Can I use this field??


import wixData from ‘wix-data’;

$w.onReady( function () {
});

var date = new Date();
// ten days old
date.setDate(date.getDate() -10);
console.log(date);// ten days old function is ok

export function button2_click(event, $w) {
$w(“#dataset1”).setFilter( wixData.filter()
.gt(‘_updateDate’, ‘date’)
);
}

What is wrong?? Thanks anyway…

Hey,

Instead of ‘_updateDate’, try using ‘_updatedDate’

Good luck :slight_smile:
Itai

Thanks Itai, very sharp!

And yes it’s better to copy paste, but… after changing no result yet.

So,

  • I put the code also on site-level (like the other filtering codes), no result.
  • I changed the date to date.toLocaleString(‘en-GB’, { timeZone: ‘UTC’ }) (according to the type of the databasefield = 17/06/2018, 12:29:28): no result.

a. Is it possible to work with the ‘_updatedDate’-field? (There is a lock visible in the matrix-header and it’s not possible to put date/time field in a dropdownbox or datepicker)
b. Is there extra code needed to used this field?

Are there examples of this issue???

Hey Floris,

I just noticed another small error,
Instead of

.gt('_updatedDate', 'date')

Try

.gt('_updatedDate', date)

In order to match the updatedDate against the date variable you defined beforehand, and not the string “date”.

Itai

Ohhhh of course, I am still learning. Thanks a lot Itai… and YES!!! Tested and its working fine. I am glad that I am able to use this field! Now it can show only the ‘new’ database items, etc. Great!

1 Like