Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 ANSI 837 SQL Question

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-09-26 : 07:42:36
Randy writes "Im working with healthcare claims data in an ODS that stores each ANSI segment in a separate table. Specifically, Im looking at the DTP table which holds dates. Within the table there are 2 fields Im concerned with: 1) date qualifier 2) date. The values could be as follows:

1. data qualifer field would be the literal 'R8'
2. date field would be the literal '20060919'
OR....
1. date qualifier field would be the literal 'RD8'
2. date field would be the literal '20060901-20060912'

Im looking for sql code that I could use to pull all records that have a date (end date in case of RD8) between 7/1/2005 and 6/20/2006. Since the dates are literals Im not sure how to do this. Any help is appreciated. Thanx"

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2006-09-26 : 08:03:57
Can you post same sample data and expected output.. and table structure??

Chirag
Go to Top of Page

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2006-09-26 : 10:34:06
[code]select
[Column List]
from
YourTableNameHere
where
([date qualifier field] = 'R8' or [date qualifier field] = 'RD8')
and
convert(datetime,right(8,[date field])) between '7/1/2005' and '6/20/2006'
[/code]

Or some such like that....*COFFEE*

[Signature]For fast help, follow this link:
http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx
Learn SQL
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-09-26 : 11:10:24
>>convert(datetime,right(8,[date field])) between '7/1/2005' and '6/20/2006'

USE Universal format

convert(datetime,right(8,[date field])) between '20050701' and '20060620'

Yes you need coffee



Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2006-09-26 : 11:15:34
my favorite *DISCLAIMER* line:

Or some such like that....*COFFEE*




[Signature]For fast help, follow this link:
http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx
Learn SQL
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page
   

- Advertisement -