First Row and last row of database in repeater

I have a database of multiple rows of attendance punch in data. I need the first punch and last punch from the database for a particular attendance date.

For example 04-May-18 there are 19 rows. I need only first in last out in repeater as Time In & Time out. Actually its working but not the first in and last out. All data are displayed for the day

This is OnReady function …

 $w("#repeater1").onItemReady( ($w, itemData, index) => { 

            $w("#attdate").text = itemData.at_date.toDateString(); 

const strHourin = (“0” + itemData.at_in.getHours().toString()).slice(-2);
const strMinutein = (“0” + itemData.at_in.getMinutes().toString()).slice(-2);
$w(“#timeindata”).text = strHourin+“:”+strMinutein;
const strHourout = (“0” + itemData.at_out.getHours().toString()).slice(-2);
const strMinuteout = (“0” + itemData.at_out.getMinutes().toString()).slice(-2);
$w(“#timeoutdata”).text = strHourout+“:”+strMinuteout;
// $w(“#text9”).text = itemData._createdDate.toDateString();
} );
});

export function validatedate_click(event, $w) {

 wixData.query("LM_Attendance").eq("at_email", $w("#email").value).descending("at_out") 
.find() 
.then( (results) => { 

let item = results.items;
$w(“#repeater1”).data = item;
} );
}

Refer my page below. Been stuck for a long time. Help me out

https://www.ccplcnet.com/viewattendancerepeat

Hey
Just do like below in your query where you get the let item.

let firstandlast = []; // Create new array
firstandlast.push(results.items[0]); // Push first item into new array
firstandlast.push(results.items[results.items.length-1]); // Push last
$w("#repeater1").data = firstandlast;

That code will create a new array called firstandlast and then push (insert) the first [0] and the last item in your results to this new array. Then it will set the data of the repeater to that two items only. Hope this will work for you. If it does please mark the answer and TOP ANSWER.

Appreciate your swift response but the output is showing as below

Code:
On Ready…

 $w("#repeater1").onItemReady( ($w, itemData, index) => { 


           $w("#attdate").text = itemData.at_date.toDateString(); 

const strHourin = (“0” + itemData.at_in.getHours().toString()).slice(-2);
const strMinutein = (“0” + itemData.at_in.getMinutes().toString()).slice(-2);
$w(“#timeindata”).text = strHourin+“:”+strMinutein;
const strHourout = (“0” + itemData.at_out.getHours().toString()).slice(-2);
const strMinuteout = (“0” + itemData.at_out.getMinutes().toString()).slice(-2);
$w(“#timeoutdata”).text = strHourout+“:”+strMinuteout;
// $w(“#text9”).text = itemData._createdDate.toDateString();
} );

});

export function validatedate_click(event, $w) {
let fromdate = $w(‘#from’).value;
let todate = $w(‘#to’).value;
wixData.query(“LM_Attendance”).eq(“at_email”, $w(“#email”).value).between(“at_date”,$w(‘#from’).value,$w(‘#to’).value).descending(“at_out”)
.find()
.then( (results) => {
let firstandlast = ; // Create new array
firstandlast.push(results.items[0]); // Push first item into new array
firstandlast.push(results.items[results.items.length-1]); // Push last
$w(“#repeater1”).data = firstandlast;

} ); 

The output is

It is not showing the date range. Have also set the date range and from


The output is only as shown above

Check this page please

https://www.ccplcnet.com/viewattendancrepeater1

Hi

It has to be last row of the particular date not the overall query. Hope you understand for a particular date. Lets say 04-May-18 the last attendance in and attendance out

Please help me out… Need to complete the project

Ok, so you need more than one row to show up in that screen?

Yes its a date range between 26-Apr-18 to 27-May-18. The Time In has to be first Time in entry for the day Timeout has to be last Time Out entry of the day and that to be displayed as one date as Time In and Time Out