Guest User

Untitled

a guest
Jan 17th, 2018
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. +---------------+-------------------------+-------------------------+------------------+
  2. | BranchEntryID | fromDate | toDate | SundayIn |
  3. +---------------+-------------------------+-------------------------+------------------+
  4. | 24 | 2015-01-01 00:00:00.000 | 2015-01-31 00:00:00.000 | 12:00:00.0000000 |
  5. | 24 | 2015-02-01 00:00:00.000 | 2015-02-15 00:00:00.000 | 12:00:00.0000000 |
  6. | 24 | 2015-03-01 00:00:00.000 | 2015-03-31 00:00:00.000 | 00:00:00.0000000 |
  7. | 24 | 2014-01-01 00:00:00.000 | 2014-12-31 00:00:00.000 | 00:00:00.0000000 |
  8. +---------------+-------------------------+-------------------------+------------------+
  9.  
  10. SELECT
  11. *
  12. FROM
  13. [dbo].[tblBranchTimingEntry]
  14.  
  15. WHERE
  16. BranchEntryId = 24
  17. AND
  18. ('2015-01-14' BETWEEN fromDate AND toDate OR '2015-02-28' BETWEEN fromDate AND toDate)
  19.  
  20. SELECT te.*
  21. FROM [dbo].[tblBranchTimingEntry] te
  22. WHERE BranchEntryId = 24 AND
  23. '2015-01-14' < toDate AND
  24. '2015-02-28' > fromDate;
  25.  
  26. SELECT
  27. *
  28. FROM
  29. [dbo].[tblBranchTimingEntry]
  30. WHERE
  31. BranchEntryId = 24
  32. AND
  33. (('2015-01-14' < toDate AND
  34. '2015-01-14' > fromDate) or ('2015-02-28' > fromDate and '2015-02-28' < toDate) or ('2015-02-28' > toDate AND
  35. '2015-01-14' < fromDate))
Add Comment
Please, Sign In to add comment