Comparing timestamp and dates
I have a table where I store values for some metrics. The table structure is quite simple: metric id, userid, metric date and metric value.Â
When a new metric comes in, I want to check if I already have a value for that metric id & user id for the date in question.Â
I tried a query all records with 3 custom filters -Â
1. Â userid in table = incoming userid Â
2. metricid in table = incoming metricid
3. metric date = incoming metric date (or now if no date comes in)
As I am checking at day level (I cannot have 2 values for the same metric or the same user for the same day) I tried using an epoch time filter to calculate days lapsed from start of epoch. But that did not work. I cannot find the format timestamp filters in the query all records either so I am a bit lost on how to check equality between two fields at a partial timestamp level (just the date part).Â
I could probably use some loops or array filters (?), but seems an overkill. If I do a query all records, and the resulting array has a count > 0 than I dont do any updates, as I already have the value.Â
Any help is appreciated. Thanks!
Other
18 replies