Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- +---------------+-------------------------+-------------------------+------------------+
- | BranchEntryID | fromDate | toDate | SundayIn |
- +---------------+-------------------------+-------------------------+------------------+
- | 24 | 2015-01-01 00:00:00.000 | 2015-01-31 00:00:00.000 | 12:00:00.0000000 |
- | 24 | 2015-02-01 00:00:00.000 | 2015-02-15 00:00:00.000 | 12:00:00.0000000 |
- | 24 | 2015-03-01 00:00:00.000 | 2015-03-31 00:00:00.000 | 00:00:00.0000000 |
- | 24 | 2014-01-01 00:00:00.000 | 2014-12-31 00:00:00.000 | 00:00:00.0000000 |
- +---------------+-------------------------+-------------------------+------------------+
- SELECT
- *
- FROM
- [dbo].[tblBranchTimingEntry]
- WHERE
- BranchEntryId = 24
- AND
- ('2015-01-14' BETWEEN fromDate AND toDate OR '2015-02-28' BETWEEN fromDate AND toDate)
- SELECT te.*
- FROM [dbo].[tblBranchTimingEntry] te
- WHERE BranchEntryId = 24 AND
- '2015-01-14' < toDate AND
- '2015-02-28' > fromDate;
- SELECT
- *
- FROM
- [dbo].[tblBranchTimingEntry]
- WHERE
- BranchEntryId = 24
- AND
- (('2015-01-14' < toDate AND
- '2015-01-14' > fromDate) or ('2015-02-28' > fromDate and '2015-02-28' < toDate) or ('2015-02-28' > toDate AND
- '2015-01-14' < fromDate))
Add Comment
Please, Sign In to add comment