# Count (in seconds) how long a value is '1'

**URL:** <https://community.influxdata.com/t/count-in-seconds-how-long-a-value-is-1/28554>\
**Category:** Fluxlang\
**Created:** [February 11, 2023, 9:47am UTC](https://community.influxdata.com/t/count-in-seconds-how-long-a-value-is-1/28554 "2023-02-11T09:47:39Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Thomas\_Decock](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/thomas_decock/32/8021_2.png) [@Thomas\_Decock](https://community.influxdata.com/u/Thomas_Decock)\
**Post date:** [February 11, 2023, 9:47am UTC](https://community.influxdata.com/t/count-in-seconds-how-long-a-value-is-1/28554/1 "2023-02-11T09:47:39Z")

</div>

dear all,

I want to measuere how long we are using our smartphones during the day,  
so eveytime the smartphone is active a ‘1’ is sent to the influx database, and when the phone is not active anymore, a value ‘0’ is sent., so i want the sum of all the times (in seconds) during a certain timeperiod (1 day) t that the value is ‘1’: for example  
10:15:05 → 1  
10:16:05 → 0  
10:30:30 → 1  
10:30:45 → 0

so the flux querry should return ‘75’ (60 + 15) .

can someone help me with this?  
regards,  
Thomas

---

_[View the full topic](https://community.influxdata.com/t/count-in-seconds-how-long-a-value-is-1/28554)._
