[Solved] I want to set the display period

Thank you for reading.

There are 2dates in the database.

1date is the display start date named ‘dayfrom’
2nd date is the display end date named ‘dayto’

The database name ‘news’

this is my code;

import wixData from 'wix-data';

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

export function QuoteArray(){
 const today = new Date(); 
 
// ...
wixData.query("news")
  .between("today", 'dayfrom', 'dayto')
 
  .find()
.then( (results) => {
 
  } )
  .catch( (error) => {
 let errorMsg = error.message;
 let code = error.code;
  } );}

Please tell me where is wrong.

You can change filteration method arguments to =====> wixData . query ( “news” ). between ( ‘dayfrom’ , ‘dayto’ ). find (). then (( results ) => {})

Hi Poornima Kalinge,
Thank you for your answer.
I try but not work ; ;

Could you help me anyone?

In Database ,
Does Both dayfrom and dayto are the Date Field ?


Like this ?

import wixData from ‘wix-data’ ;

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

export function QuoteArray(){
const today = new Date();

wixData.query( ‘news’ )
.gt( ‘dayfrom’ , today)
.lt( ‘dayto’ , today)
.find().then(results => {
console.log(results)
} )
. catch ( (error) => {
let errorMsg = error.message;
let code = error.code;
} )

;}

// This may be your final Code

Hi Er.Muthu K ,
Thank you for your reply.

That’s right this is Both dayfrom and dayto are the Date Field.


And I try your code, but its not work.

test1 must be hide, because Feb 01~ Feb 10
But its display yet…

What is your getting in your Console ?

Yes sure.

In Console ?

What is the Output of Line#14 ?

Is this?

import wixData from ‘wix-data’ ;

$w.onReady( async function () {

const today = new Date();

let query = await wixData.query( ‘news’ )
.lt( ‘dayfrom’ , today)
.gt( ‘dayto’ , today)
.find().then(results => {
console.log(results);
console.log( "QUERY = " +query);
} )
. catch ( (error) => {
let errorMsg = error.message;
let code = error.code;
} )

;

});

Test 1 Not Came With the Below Video;

Now It Will Work

Please Update with this Code.
I made minor Changes .

If you see the Video , You will not Get test1 As Expected.

:slight_smile:

Thank you for your kindness.

But not work on website.

Surely the total count is 2 on console log, but test 1 is display…; ;

Sorry several times ask…

Have you sync Sandbox to Live ?

The Above text is URL ,
Please copy and Paste it with Browser’s URL Bar