I need to make a query to summarize all money spent during last day.
The documents have a field with price which I want to summarize and the field with timestamp.
Firestore stores timestamps in this format: June 12, 2024 at 6:27:01 PM UTC+3
, but I don’t really need all of this data. I just want to make a comparison to make sure that current day and day of timestamp are the same, and I don’t understand how to do it clean and efficiently.
I tried to convert timestamp value to match the format of Flutter, when adding data to Firestore. Query to add data to Firestore looked like this:
Future<void> addGood(
String good, client, int amount, double price, String username) {
return goods.add({
'good': good,
'amount': amount,
'price': price,
'client': client,
'username': currentUser!.email,
'timestampday': Timestamp.now().toDate().toString()
});
}
Then I changed the way this collection stores timestamps to string format. Probably it could help somehow, but I don’t know how to work with this data after converting it.
1rre7 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1