Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Convert UTC to Central Time zone in SQL Post Reply Post New Topic
Author Message
nhopp4
Groupie
Groupie


Joined: 03 Oct 2012
Location: United States
Online Status: Offline
Posts: 62
Quote nhopp4 Replybullet Topic: Convert UTC to Central Time zone in SQL
     Posted: 23 Nov 2015 at 6:52am
Hello everyone,
I am using the command feature inside crystal reports and I need to convert my datetime variable to central time from UTC.

I am also using parameters in this section.

SELECT [Events].[Starttime] AS StartTime

WHERE StartTime BETWEEN {?TimeStart} and {?TimeEnd}

I have the whole code but these are the tables I am looking for.

Thanks for the help!
Nick
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 23 Nov 2015 at 9:08am
There is a function in Crystal Reports (at least in 2011) that is called ShiftDateTime.  I have never actually used it.  But I know that it is supposed to do the math to change from one time zone to another.
IP IP Logged
nhopp4
Groupie
Groupie


Joined: 03 Oct 2012
Location: United States
Online Status: Offline
Posts: 62
Quote nhopp4 Replybullet Posted: 23 Nov 2015 at 9:32am
Thanks Kevlray after googling I found this. It won't work with DST but will get me by for what I need it for.

DATEADD(second, DATEDIFF(second, GETUTCDATE(), GETDATE()), Events.Starttime) AS StartTime
IP IP Logged
nhopp4
Groupie
Groupie


Joined: 03 Oct 2012
Location: United States
Online Status: Offline
Posts: 62
Quote nhopp4 Replybullet Posted: 24 Nov 2015 at 8:22am
For some reason when I put in say 11PM for the startdate parameter in the command it pulls the records for 5PM. How do I get the Parameters to match up with my conversion above? Any ideas?

Thanks!
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