Having Trouble with Expression from Template - wanting only current year data

So I followed the Time clock video posted by Appsheet and included it into my app with a template that sends an email with the total hours. I created this a year ago, and now I am getting not only 2022 data, but now also 2023 data on the same template.  I only have one person to track but a year ago as part of testing I was also logging hours.    

I have fiddled and fiddled with trying to only get this years data to pull with mixed results.  I am hoping someone could help me.  Ultimately I made a copy of the database and removed 2022 data for now. But I want it all in the same spreadsheet.  

These are the queries from the template:

<<If: (COUNT(SELECT([Related TimeCards][ID], [WeekNum]=WEEKNUM(NOW())))>0)>>

This I can change to =WEEKNUM(TODAY()-1)))

And it filters out for the one employee, but the testing I was doing a year ago still lists my time from 2022 as there are no 2023 entries for myself.

Also, the last section just lists hours from "some date" IDK what date this is pulling from, I am assuming the same week in 2022. No matter what I do I can't seem to change what appears here.

Here is the whole template:

Employees

 

<<Start:SELECT(Employees[Email],TRUE)>>

 

Email: <<[Email]>>


Name: <<[_ComputedName]>>

Rate: <<[Rate]>>

<<If: (COUNT(SELECT([Related TimeCards][ID], [WeekNum]=WEEKNUM(NOW())))>0)>>

TimeCard

Date

Time In

Time Out

Calculated Time

Description

<<Start: SELECT([Related TimeCards][ID],[WeekNum]=WEEKNUM(NOW()))>><<[Date]>>

<<[Time In]>>

<<[Time Out]>>

<<[Calculated Time]>>

<<[Description]>><<End>>

<<EndIf>>

<<If: (COUNT(SELECT([Related TimeSheets][ID], [WeekNum]=WEEKNUM(NOW())))>0)>>

TimeSheet

Sun

Mon

Tues

Wed

Thurs

Fri

Sat

Total Hours

Total Amount

<<Start: SELECT([Related TimeSheets][ID],[WeekNum]=WEEKNUM(NOW()))>><<[Sunday]>>

<<[Monday]>>

<<[Tuesday]>>

<<[Wednesday]>>

<<[Thursday]>>

<<[Friday]>>

<<[Saturday]>>

<<[Total Hours]>>

<<[Total Amount]>><<End>>

<<EndIf>>

<<End>>

 

 

 

0 3 91
3 REPLIES 3


@TripleTHH wrote:

only get this years data


Create a slice that includes only the rows you want. Then, include that slice's rows in your email.

Also WEEKNUM() function  disregards calendar year.  It will give records with matching week number from all years.

You may want to instead use EOWEEK() function , something like below


@TripleTHH wrote:

<<If: (COUNT(SELECT([Related TimeCards][ID], [WeekNum]=WEEKNUM(NOW())))>0)>>


Instead: 

<<If: (COUNT(SELECT([Related TimeCards][ID], EOWEEK([Date])=EOWEEK(NOW())))>0)>>


<><<[Sunday]>>@TripleTHH@TripleTHH wrote:

<<Start: SELECT([Related TimeCards][ID],[WeekNum]=WEEKNUM(NOW()))>><<[Date]>>


Instead:

<<Start: SELECT([Related TimeCards][ID],EOWEEK([Date])=EOWEEK(NOW()))>><<[Date]>>


@TripleTHH wrote:

<<Start: SELECT([Related TimeSheets][ID],[WeekNum]=WEEKNUM(NOW()))>><<[Sunday]>>


Instead:

<<Start: SELECT([Related TimeSheets][ID],EOWEEK([Date])=EOWEEK(NOW()))>><<[Sunday]>>

 

EOWEEK() help article:

EOWEEK() - AppSheet Help

 

 

<<If: (COUNT(SELECT([Related TimeCards][ID], YEAR([Date]) = YEAR(TODAY()))) > 0)>>

<<Start: SELECT([Related TimeCards][ID], YEAR([Date]) = YEAR(TODAY()))>>


<<[Date]>> <<[Time In]>> <<[Time Out]>> <<[Calculated Time]>> <<[Description]>>
<<End>>
<<EndIf>>

<<If: (COUNT(SELECT([Related TimeSheets][ID], YEAR([Date]) = YEAR(TODAY()))) > 0)>>


<<Start: SELECT([Related TimeSheets][ID], YEAR([Date]) = YEAR(TODAY()))>>
<<[Sunday]>> <<[Monday]>> <<[Tuesday]>> <<[Wednesday]>> <<[Thursday]>> <<[Friday]>> <<[Saturday]>> <<[Total Hours]>> <<[Total Amount]>>
<<End>>
<<EndIf>>

Top Labels in this Space