cancel
Showing results for 
Search instead for 
Did you mean: 

Date Off by One Day

0 Kudos

Hello!

I'm having issues with dates appearing one day early in *some* instances.

When building a report in Crystal Reports 11.5.0.313, all of the dates passed into Crystal appear correct when previewing said report. Once the report is saved and pushed to our servers, the majority of the time the dates appear correct but in some instances, the dates are one day off.

For instance, if I create a report based on the date "07/10/1980", the report PDF shows the correct date. However, if I create a report based on the date "03/15/1971", when the PDF loads, it shows the date as "03/14/1971". The date field is does print correctly more often than not. I have verified the actual date in data is indeed correct and doesn't show incorrectly until the report is generated. In an attempt to resolve this issue, I've tried altering the date field in a formula as well as adding 10 hours to the date. I've had no luck in finding a resolution

After searching, I've found minimal issues in recent years, which makes me wonder if it's version related. I can reproduce this behavior on a test server that's running:

Crystal Reports Basic Runtime for Visual Studio 2008 - Version 10.5.1.0

Crystal Reports Basic Runtime for Visual Studio 2008 (x64) - Version 10.5.0.0

SAP Crystal Reports runtime engine for .NET Framework (32-bit) - Version 13.0.5.891

SAP Crystal Reports runtime engine for .NET Framework (64-bit) - Version 13.0.5.891

Any advice is greatly appreciated.

DellSC
Active Contributor

I updated the tag on your question to something more appropriate. You should get a better answer under the .NET SDK tag that I used.

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

As a follow up, I believe the issue pertains to Daylight Savings Time. I've done quite a bit of testing. When using DateTime variables without a timestamp (01/26/2021 00:00:00.000), eventually a time is added. In our situation, the timestamp was being added in code before we sent the data off to Crystal Reports. Usually, CR handles this seamlessly but since we're using an outdated version, my *assumption* is there exists a bug when Crystal Reports converts the date before displaying it to the end user. Sometimes the dates appear as intended while other times, the timestamp gets converted to 11:00 PM the day before, which then shows the date as one day off.

Upgrading is the obvious solution but in a time sensitive situation, I needed to come up with a fix. For anyone else in this situation, here are the options I've found. The ultimate goal is to forward the time past 00:00:00.000 to prevent a time zone issue where CR shifts the DateTime backwards too far.

1. Add a few hours to the date in a CR formula.

2. Send the DateTime variable to CR as a string. I haven't tested this option but I believe if the data is passed as a string, CR won't shift the date.

3. Use ShiftDateTime in a CR formula to alter the time zone (as seen below).

4. Shift the DateTime variable in code before it's passed off to Crystal.

ToText(ShiftDateTime(*DATETIMEVARIABLE*}, UTC,000,CST,-360,CDT,-360;3.2.0/02:00,11.1.0/02:00), MM/dd/yyyy HH:mm:ss tt)

DATETIMEVARIABLE-- Original DateTime

UTC-- Starting Time Zone

000-- Offset

CST-- Ending Time Zone

-360-- Time Offset in Minutes (-6 Hours)

CDT-- Daylight Savings Time

-360-- Time Offset in Minutes (-6 Hours)

3.2.0/02:00-- DST starting on Sunday of the second week of the third month at 2:00 AM

11.1.0/02:00-- DST ending on Sunday of the first week of the eleventh month at 2:00 AM

ToText(DATESHIFT, MM/dd/yyyy HH:mm:ss tt)-- Formats the resulting date. The included time format was added for testing purposes.

We opted to alter the DateTime variable in code before we sent it off to CR.

Thank you for all of the assistance.

Answers (3)

Answers (3)

0 Kudos

Hi Michael,

Thanks for explaining what the issue is, now it makes sense why it's missing data.

I did a quick Google search and found this to adjust for in code:

https://stackoverflow.com/questions/10665678/check-if-daylight-savings-is-in-effect

Thanks again

Don

0 Kudos

Solution is to upgrade to CR for VS SP 29 which works in VS 2010->2019 and see if that fixes the issue.

https://wiki.scn.sap.com/wiki/display/BOBJ/Crystal+Reports%2C+Developer+for+Visual+Studio+Downloads

XI R2 is 15+ years old and you are using the original release, many patches have been applied to XI R2 which likely fixed the issue.

R2 is no longer available so only option is to upgrade and upgrade the Report as well.

https://www.sapstore.com/solutions/99043/SAP-Crystal-Reports

Don

0 Kudos

Much Thanks.