see the sp below. this may help you. i declare it at the top and use it in the where statement.
BEGIN
--Select GUID from cv3PatientCareDocument where Name = 'Center Adv. Digestive Care'
--loc.ParentGUID = 2000001000061001= 'Cornell'
------------------------------------------------------------------------------------------------------------------------------------
DECLARE
@start_date datetime,
@end_date datetime
--use convert to mm/dd/yyyy with default Start_time 12:00:00 and default End_time 11:59:59
SELECT @start_date = convert(datetime,convert(varchar(10), @StartDate, 101))
SELECT @end_date = dateadd(ss, -1, dateadd(dd, 1,convert(datetime,convert(varchar(10), @EndDate, 101))))
Declare @RawInfo Table(
CAMPUS_SITE varchar(10),
Patient varchar(100),
MRN char(20),
Account char(20),
ClientDocGUID numeric(16,0),
EnteredBy varchar(50),
Hospital_unit varchar(50) )
Insert into @RawInfo
Select
CAMPUS_SITE = 'EAST',
Patient = cv.ClientDisplayName,
MRN = cv.IDCode,
Account = cv.VisitIDCode,
ClientDocGUID = cd.GUID,
EnteredBy = u.DisplayName,
Hospital_unit=loc.name
FROM
dbo.CV3ClientDocument AS cd with (nolock)
INNER JOIN
dbo.CV3ClientVisit AS cv with (nolock) ON cd.ClientVisitGUID = cv.GUID
and cd.PatCareDocGUID= 9000001402102020
INNER JOIN
dbo.CV3User AS u with (nolock) ON cd.UserGUID = u.GUID
and u.GUID in (select u2.GUID from cv3user u2
where u2.Displayname in ('Dexter, Karly',
'Fischer, Karen A',
'Lynn, Kelly Ann',
'Merrigan, Shannon'))
INNER JOIN
dbo.CV3Location as loc with (nolock) ON cv.CurrentLocationGUID = loc.GUID
and loc.ParentGUID = 2000001000061001 and loc.typecode='Unit'
Where
cv.TypeCode='Inpatient'
and cv.admitdtm between @start_date and @end_date