Comparing date ranges

后端 未结 10 1446
予麋鹿
予麋鹿 2020-11-22 16:10

In MySQL, If I have a list of date ranges (range-start and range-end). e.g.

10/06/1983 to 14/06/1983
15/07/1983 to 16/07/1983
18/07/1983 to 18/07/1983
         


        
10条回答
  •  甜味超标
    2020-11-22 16:28

    Look into the following example. It will helpful for you.

        SELECT  DISTINCT RelatedTo,CAST(NotificationContent as nvarchar(max)) as NotificationContent,
                    ID,
                    Url,
                    NotificationPrefix,
                    NotificationDate
                    FROM NotificationMaster as nfm
                    inner join NotificationSettingsSubscriptionLog as nfl on nfm.NotificationDate between nfl.LastSubscribedDate and isnull(nfl.LastUnSubscribedDate,GETDATE())
      where ID not in(SELECT NotificationID from removednotificationsmaster where Userid=@userid) and  nfl.UserId = @userid and nfl.RelatedSettingColumn = RelatedTo
    

提交回复
热议问题