Click here to Skip to main content
16,008,175 members

Comments by Sikaman (Top 17 by date)

Sikaman 10-Apr-13 17:40pm View    
Thank you, I have it corrected. Perfectly understood.
Sikaman 10-Apr-13 17:37pm View    
Jose, thank you. It works. Much appreciated!
Sikaman 10-Apr-13 13:14pm View    
Hi Zoltan, I tried the solution to no avail. This is what I did:

and select distinct MTMRN from (sh-sql01.DataWarehouse-SQLQuery.Exam_SchedProv_Age_v2.sql*)

and this is the message:

Msg 156, Level 15, State 1, Line 23
Incorrect syntax near the keyword 'select'.
Msg 102, Level 15, State 1, Line 23
Incorrect syntax near '-'.
Sikaman 10-Apr-13 10:39am View    
I have since solved this problem. Solution: and datediff(year,ServiceDate,getdate()) < = 10
Sikaman 10-Apr-13 10:12am View    
Morning, Marciej: Not sure how your site works, but if you're up and about...
I am adding one additional line to further extract data under a 'ServiceDate' on the dataset that was returned. I want to extract those between now, current date, and 10 years ago.
Typical data in the 'ServiceDate' column looks like the following:
2006-08-11 01:04:00.000
2006-08-11 01:04:00.000
2006-08-11 01:04:00.000
2006-08-11 01:04:00.000
2003-03-14 12:10:00.000
2003-03-14 12:10:00.000
2003-05-23 10:04:00.000
2003-05-23 10:04:00.000

10 years ago from today will be 2003-04. This means if what I wrote executes correctly, I will have 6 returns out of the 8.
This is what I wrote: and datediff(year,ServiceDate,getdate()) between Now() and 10.
Query returned an error message: Msg 195, Level 15, State 10, Line 22
'Now' is not a recognized built-in function name.

What am I doing incorrectly. Is there a better line to extract this. Thanks