Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: SQL Date\Time Paramter Post Reply Post New Topic
Author Message
jbalbo
Senior Member
Senior Member
Avatar

Joined: 17 Feb 2011
Online Status: Offline
Posts: 219
Quote jbalbo Replybullet Topic: SQL Date\Time Paramter
     Posted: 10 Aug 2011 at 10:33am
Hi,
 
Does anyone know how I can default the time portion of date\time passed to crystal via a Stored procedure?
When the paramter comes up it defaults to the current time.
I would really like the start date to be 0:00 and the End date time to be 23:59
 
Of course I would love to eliminate the time altogeter, but told it wass impossible
 
Thanks
Joe
 
IP IP Logged
sharona
Senior Member
Senior Member
Avatar

Joined: 16 Oct 2008
Location: United States
Online Status: Offline
Posts: 255
Quote sharona Replybullet Posted: 10 Aug 2011 at 10:53am
You need to convert the datetime in the stored procedure to a date
 
i use this

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))))

sharona
IP IP Logged
jbalbo
Senior Member
Senior Member
Avatar

Joined: 17 Feb 2011
Online Status: Offline
Posts: 219
Quote jbalbo Replybullet Posted: 10 Aug 2011 at 11:00am
thanks for getting back,
can I do this in the WHERE statement?
 
IF so can u give an example?
 
Thanks
Joe
 
IP IP Logged
sharona
Senior Member
Senior Member
Avatar

Joined: 16 Oct 2008
Location: United States
Online Status: Offline
Posts: 255
Quote sharona Replybullet Posted: 11 Aug 2011 at 2:24am

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

 

sharona
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum