- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2020
05:37 AM
07-27-2020
05:37 AM
Hi, how can I declare datetime variable and then use it in a query?
For example:
Solved! Go to Solution.
1 ACCEPTED SOLUTION
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2020
08:07 AM
08-20-2020
08:07 AM
Hi,
The SQL Report Builder doesn't support variable declaration syntax like your example - try a WITH clause at the beginning. You can use this to effectively create a temporary table, which you can then select your variable from.
For example:
with tmp as (select '2020-08-20'::DATE as mydate ) select "entity_id", "created_at" from "sales_order" where "created_at" >= (select mydate from tmp) limit 10;
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2020
05:45 AM
07-27-2020
05:45 AM
Re: To declare datetime variable and then use it in a query?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2020
06:57 AM
08-20-2020
06:57 AM
Re: To declare datetime variable and then use it in a query?
any answer?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2020
08:07 AM
08-20-2020
08:07 AM
Hi,
The SQL Report Builder doesn't support variable declaration syntax like your example - try a WITH clause at the beginning. You can use this to effectively create a temporary table, which you can then select your variable from.
For example:
with tmp as (select '2020-08-20'::DATE as mydate ) select "entity_id", "created_at" from "sales_order" where "created_at" >= (select mydate from tmp) limit 10;