Sorry, because I know this must be easier than I am making it, but I am trying to set a value in a database based on a column with a number.
In general, I am trying to set a flag based on the rollover current month which I have represented in a database by number 1-12.
I am able to obtain and generate the day of the month and the month, but don’t seem to be able to filter and set another value based on that. I am not sure if the problem is having to do with filter by a numeric (so I created text equivalent fields) but I still have problems trying to use functions that all seem to take strings.
Here’s my code - I’ve tried a lot of variations, creating text equivalent columns (though I’d rather just search and filter on a number) and for comparison purposes, how do I convert a number to a string.
I’m not sure I’m going about any of this the right way.
Would very much appreciate some steering.
Thank you!
import wixData from “wix-data” ;
var d = new Date();
var Month = (d.getMonth()+ 1 )
var Day = (d.getDate())
$w.onReady( function () {
var OldMonth = 0 ;
// my modulo function
if (Month === 1 ) OldMonth = 12 ;
else OldMonth = Month - 1 ;
if (Day === 1 ){ //if the month has rolled over, reset a flag in the database - e.g., set the featured month column as a “yes” and clear the previous month
//set Old Month featured column to “”
//set New Month featured column to “yes”
$w( “#dataset10” ).setFilter(wixData.filter().contains( “textmonth” , “” + Month)).testfeature = “yes” ;
$w( “#dataset10” ).setFilter(wixData.filter().contains( “textmonth” , “” + OldMonth)).testfeature = “” ;
}
});