Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. SQL Server
  3. Question
SQL Server

How to cast an interval postgresql?

Asked by David Edmunds Mar 17, 2023 1.1K views 1 answer
Share

About this question

I have a table where

      date               | interval
 juin 1, 2022, 12:00 AM  | 0 years 0 mons 0 days 0 hours 1 mins 58.963179 secs
 juin 2, 2022, 12:00 AM  | 0 years 0 mons 0 days 0 hours 2 mins 34.083955 secs
 juin 3, 2022, 12:00 AM  | 0 years 0 mons 0 days 0 hours 2 mins 51.152488 secs
etc...

I want to cast the interval to have a timestamp. I am in postresql

 SELECT 
 DATE_TRUNC('day', "order_date") as date_authorised,
 avg("difference") AS "avg_time"
 FROM "test"
 where  date_trunc('day',order_date) GROUP BY DATE_TRUNC('day', "order_date")   
that's my code

Your answer

1 Answer

More SQL Server discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest SQL Server Blogs

Guides, tips and career advice on SQL Server from JanBask experts.