Skip to content

Tag: date

MySQL- Find records with overlapping period

I have a table hotel_booking reference start_date numberOfDays ABC 11-08-2021 2 DEF 12-08-2021 2 GHI 13-08-2021 3 JKL 10-08-2021 2 So the first task I wanted was to get all bookings which has startDate between x and y date which is straight forward query This returns me ABC and DEF which is perfect. Now I wan…

ASP classic select date BETWEEN dates on SQL Server

I run the next query in my classic asp code and it run perfect. it returns results between the days “from” and “to” However,I cannot find out what is wrong with the next query: I want it to return the results of the last week that are recorded in the database. Any Ideas? The query is o…

SQL Server – Can’t change datetime to date

I have this sql which has some date format issue, problem is that I can freely change EndDate to whatever I want, but for StartDate I can’t seem to change it one bit, it always have this timestamp that I am trying to get rid of. Basically whatever I do in varchar, date or any format I just can’t c…

Date range to row in postgres

I have a table in postgres like this: id open_date close_date 5 2006-08-04 2019-12-31 There exist 4897 days between them. I need to turn the date range to date to have one record per day. For example: id open_date close_date valid_date 5 2006-08-04 2019-12-31 2006-08-04 5 2006-08-04 2019-12-31 2006-08-05 5 20…

SQL consolidate overlapping dates based on criteria

I’m trying to merge overlapping dates between Admit and discharge dates of patients. There are a few edge cases which I couldn’t cover in the query. Input Expected Output Query I used the logic that was here But this doesn’t cover the edge case for ID 2 and 3. Also the subquery is slower whe…

Want to convert timestamp to date format in hive

want to convert this number ‘20210412070422’ to date format ‘2021-04-12’ in hive I am trying but this returns null value from_unixtime(unix_timestamp(eap_as_of_dt, ‘MM/dd/yyyy’)) Answer The best methoid is to do without unix_timestamp/from_unixtime if possible and in your c…