Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

194
Views
fill in a HTML table with all days of month and date table from postgresql (javascript)

I don't understand how to use generate_series to populate an HTML table where the 'key' of <tr> is the days of the month depending on the month and year that is selected with an <input type='month'>.

For now (thanks to the answers I got right here), I generated the query that only brings me the days of the month and year when I select it in the select month.

Something like this:

SELECT
    *
FROM (
    SELECT
        folio,
        fecha,
        extract(month FROM fecha) = $3 AS mes,
        EXTRACT(YEAR FROM fecha) = $4 AS anio,
        temperatura
    FROM
        medicion) m
WHERE
    mes = TRUE
    AND anio = TRUE
ORDER BY
    fecha ASC

And got this in the HTML table:

fecha temperatura
2022-03-04 60
2022-03-07 50
2022-03-09 70

But I need something like this:

fecha temperatura
2022-03-01 0
2022-03-02 0
2022-03-03 0
2022-03-04 60
2022-03-05 0
2022-03-06 0
2022-03-07 50
2022-03-08 0
2022-03-09 70
2022-03-10 0

with all days and different for each month.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Something like this:

SELECT
    t.dt,
    coalesce(temperatura, 0)
FROM
    generate_series('03/01/2022'::timestamp, (('03/01/2022'::timestamp + interval '1 month') - interval '1 day'), '1 day') AS t (dt)
LEFT JOIN 
    medicion ON t.dt = medicion.fecha;

This assumes medicion.fecha is a date field. Also you would need to build the start date for the generate_series() from the input values to enter into the function, for instance $3/01/$4

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!