locked
How to find all dates less than a date in all date columns in a table RRS feed

  • Question

  • Hoping there is a clever way to find any date in a SQL table which is less than a given date.  The tricky part is that the data table contains many datetime columns each of witch might contain dates less than the giver date.


    ISV using VB.net and SQL Server

    Monday, August 26, 2019 4:10 PM

Answers

  • There is no built in way to compare multiple columns.  You could pivot the date fields, but it is probably more trouble than it is worth for <10 date columns.

    • Marked as answer by Jeff07 Monday, August 26, 2019 4:33 PM
    Monday, August 26, 2019 4:24 PM

All replies

  • Can you mark up a sample of your question and your expected result from your sample? Thanks.
    Monday, August 26, 2019 4:15 PM
  • There is no built in way to compare multiple columns.  You could pivot the date fields, but it is probably more trouble than it is worth for <10 date columns.

    • Marked as answer by Jeff07 Monday, August 26, 2019 4:33 PM
    Monday, August 26, 2019 4:24 PM
  • Thank you.   Just hoping for some magic.

    Have several data tables each with many date columns per table.


    ISV using VB.net and SQL Server

    Monday, August 26, 2019 4:33 PM