Username DateStart DateFinish James 2017-07-01 2017-09-14 Luigi 2017-08-02 2017-09-18 Francesco 2017-09-03 2017-10-25
How is the sql difference calculated between two date columns in days?
You can just subtract them like
select "DateFinish"::date - "DateStart"::date;
And if the date column has a data date, then you can simply do:
select "DateFinish" - "DateStart"
If you want to see the difference in quantity (10 instead of the date value that has 10 days in it), you can get it with:
select extract(day from "DateFinish" - "DateStart")
Try it. It extracts the number of days between two dates and creates a column called "days":
select extract(day from DateFinish - DateStart) as days from MyTable;
Source: https://habr.com/ru/post/1272743/More articles:Disconnect browser header and footer from print page - javascriptExtract bits using bit manipulation - cReorder string using array / javascript indexes - javascriptHow can I handle oracle decimal numbers with the GoldenGate "Kafka" / "Kafka connect" handler? - oracleThe number of alternating sequences up / down - cLinq: extension method in IEnumerable to automatically perform null checks when fetching - c #How to declare raw types in Kotlin? - javaBuilding a C # object for JSON - jsonEncoder & Decoder Custom Dictionary for Codable in Swift 4 - dictionaryCreate a Cartesian product extension of two variational, non-pig parameter templates - c ++All Articles