Querying records from last 7 days using 'YYYY-MM-DD' format
Hi there,
I'm a bit stuck and would love some help — I'm trying to query only the records from the last 7 days from our Plaid database table. Plaid only provides the date of a transaction, not a timestamp, so we've been saving this data as a date field with 'YYYY-MM-DD'.
In theory, the query should be as simple as this, however comparing dates and timestamps isn't working, and I can't seem to figure out an easy way to cast the plaid_transaction.date
field to a timestamp.
Any suggestions?
Jack
Comments
-
Hi @jackb
I'd try creating a variable before that step and run a
parse_timestamp
filter on it:https://docs.xano.com/working-with-data/data-type-filters/timestamp-filters#parse_timestamp
Then it'll be treated as a real timestamp so you can compare it in the query.
-
@jakespirek thanks for the thought!
ideal world, i'd include the conditional in the 'query all records' step since this table is quite large and I'd rather only return records in the last 7 days.
I'll try out your solution or just write some SQL with the direct DB query.
-
Ah, yes I see what you mean.
Another thought: Maybe you can add a new timestamp field and do that parsing when you save the Plaid results to the table so it's a true timestamp so you can do this query a little easier going forward?
Yes, that would involve running a task in the meantime to go through and update the past records, but future queries would be easier.
But if you're able to do it via SQL with direct db access, awesome! Would love to hear how you eventually solve it! 💪
-
@jakespirek — I ended up creating the timestamp field when ingesting the data (having one 'date' field and one 'timestamp' field representing the date) and the calculations are working properly. Thanks for the help!
-
Thanks for sharing @jackb! Glad you found a solution that works for you! 🙌
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback