Compare Date End of first record with Start Date of Second

0

Hello.

I'm having trouble crafting a SELECT that checks if the End Date of the first record of the query is greater than the start date of the second.

The database in question is for notes, and for some reason, some notes have a start date smaller than the previous end date.

To better illustrate, I'll use the terms Attendance, Pending and Time, remembering that a call can contain more than one pending and a pending call may contain more than one time.

Theintentistoidentifywhichtimeswithinaparticularservicearetheenddategreaterthanthestartdateofthenextrecord.

Thisonlywithintheservice,iecannotbecomparedforexampletheenddateofCDTEMPO256261withthestartdateofCDTEMPO256269.Whytheyareofdifferentattendances.

Ineedideasonhowtoidentifythesetimes.ItdoesnotnecessarilyhavetobeSELECT,itcouldbebyprocedurealsowithnoproblems.InthisselectorprocedureIneedtodisplaythesamefieldsastheimageabove,andreturnonlytherecordthathasthestartdatesmallerthantheenddateofthepreviousrecord.

Intheorytheselect/procedureshouldreturnthis:

Thank you in advance!

    
asked by anonymous 01.06.2017 / 22:35

1 answer

0

You can check the record by passing the start date of the service and the end date of the previous service. All results that return (value) > = (00:00:00) are records that do not overlap the timeframe of the current date-1 date. The records that return (value) < (00:00:00) are records that have time overlap.

SELECT TIMEDIFF(STR_TO_DATE( "01/05/2014 09:00:00", "%d/%m/%Y %H:%i:%s" ), 
STR_TO_DATE( "01/05/2014 09:00:00", "%d/%m/%Y %H:%i:%s" )) diferenca

SELECT TIMEDIFF(STR_TO_DATE( "01/05/2014 11:00:00", "%d/%m/%Y %H:%i:%s" ), 
STR_TO_DATE( "01/05/2014 10:00:00", "%d/%m/%Y %H:%i:%s" )) diferenca

SELECT TIMEDIFF(STR_TO_DATE( "01/05/2014 12:00:00", "%d/%m/%Y %H:%i:%s" ), 
STR_TO_DATE( "01/05/2014 13:00:00", "%d/%m/%Y %H:%i:%s" )) diferenca
    
02.06.2017 / 01:23