Re: Passing a dynamic interval to generate_series()

2024-07-01 Thread Shammat
Igal Sapir schrieb am 01.07.2024 um 00:39: > I am trying to pass a dynamic interval to generate_series() with date range. > > This works as expected, and generates a series with an interval of 1 month: > > SELECT generate_series( >     date_trunc('month', current_date), >     date_trunc('month',

Re: Passing a dynamic interval to generate_series()

2024-07-01 Thread Francisco Olarte
Hi Igal: On Mon, 1 Jul 2024 at 01:17, Igal Sapir wrote: > I actually did test the expression that I posted, but it might be casting it > twice. While your examples that you wrote show 1 month correctly: > SELECT (interval '1 ' || 'month'); > ?column? | > -+ > 00:00:01month| No

Re: Passing a dynamic interval to generate_series()

2024-06-30 Thread Igal Sapir
On Sun, Jun 30, 2024 at 3:51 PM Tom Lane wrote: > Igal Sapir writes: > > But this throws an error (SQL Error [42601]: ERROR: syntax error at or > near > > "'1 '"): > > > SELECT generate_series( > > date_trunc('month', current_date), > > date_trunc('month', current_date + interval '7 mont

Re: Passing a dynamic interval to generate_series()

2024-06-30 Thread Tom Lane
Igal Sapir writes: > But this throws an error (SQL Error [42601]: ERROR: syntax error at or near > "'1 '"): > SELECT generate_series( > date_trunc('month', current_date), > date_trunc('month', current_date + interval '7 month'), > interval ('1 ' || 'month')::interval > ) You're overt