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

336
Views
MySQL date_format( date, '%Y-%m-%d %h') as `day-hour` equivalent in Presto

I have column date column, timestamp data type.

      date
'2020-08-05 01:01:24.000'
'2020-08-05 02:02:24.000'
'2020-08-05 02:03:24.000'

I want to groupby day-hours.

So In MySQL I would do this by

    select date_format( date, '%Y-%m-%d %h') as `day-hour`
      from table 
  group by date_format( date, '%Y-%m-%d %h');

which would output:

   day-hour
2020-08-05 01
2020-08-05 02

How can I do this in Presto?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can cast those strings to TIMESTAMP and use date_trunc to truncate the timestamps to hours:

WITH data(x) AS (VALUES
    '2020-08-05 01:01:24.000',
    '2020-08-05 02:02:24.000',
    '2020-08-05 02:03:24.000')
SELECT date_trunc('hour', CAST(x AS TIMESTAMP))
FROM data
GROUP BY 1
          _col0
-------------------------
 2020-08-05 01:00:00.000
 2020-08-05 02:00:00.000
(2 rows)
over 4 years ago · Santiago Trujillo 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!