|
Posted by Erland Sommarskog on 05/27/05 00:38
(manning_news@hotmail.com) writes:
> For a given MonthName, I pull SSN, IMClinicDay, IMClinicDateLast, and
> IMClinicDateFirst. IMClinicDay contains data like "Monday AM",
> "Tuesday PM". IMClinicDateLast and IMClinicDateFirst contains date
> data in mm/dd/yy format.
No, they are declared as datetime, which means that they are in a
binary format. If you say
SELECT * FROM tbl WHERE datecol = '07/01/05'
You could get rows from from 2007-01-05, 2005-01-07 or any other
of the six possible permutations, depending on the current settings.
On the other hand:
SELECT * FROM tbl WHERE datecol = '20070105'
will always give the same set of data.
OK, so that is not what you asked about, but since you had an apparent
misunderstanding about datetime, I figured I should point it out.
> I need to pull IMClinicDay for the date given
> in IMClinicDateFirst. For example, if my data looks like this:
>
> SSN: 999999999
> MonthName: July
> IMClinicDay: Monday PM
> IMClinicDateLast: 07/01/05
> IMClinicDateFirst: 09/01/05
>
> then I need to pull what the IMClinicDay would be for this SSN in
> September.
If I understand this correctly, you should have a look at the datename()
function in Books Online.
--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp
Navigation:
[Reply to this message]
|