• dj1202 (11/8/2012)


    Hello everyone, I have 3 fields, all text strings but all supposed to represent dates.

    Field 1: varchar in the format of '20121108'.

    Field 2 and 3: varchar string supposed to represent quarters and years. For example, '4Q12' is used to represent 4th quarter of year 2012.

    I'm trying to write a query to check if Field 1 is BETWEEN Field 2 and Field 3.

    SELECT *

    FROM Table

    WHERE CONVERT(date,Field1, 111) BETWEEN...

    Any help at all would be greatly appreciated.

    What you are describing is one of the reasons you should store datetime data in a datetime column.

    Can you post some ddl, sample data and desired output. Take a look at the first link in my signature for best practices when posting questions.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/