|
|||||||||
|
Crystal Reports Tools: Improve Performance While Saving Time and Money |
|
Crystal Reports: Time ZonesGreenwich Mean Time was established in 1675 to help mariners calculate longitude at sea. Research tells us that New Zealand was the first country to adopt a standard time for the entire country in 1868. A painfully interesting twist on time zones is Daylight Wasting Time. Politicians call it "Daylight Savings Time," even though the clock shift wastes an hour of daylight at night, causes an extra hour of daylight each morning, and causes a spike in both traffic accidents and industrial injuries. Fans of Ray Bradbury are familiar with the manipulative language technique of naming an undesirable program by an innocent-sounding or even positive name. In the interests of intellectual honesty, we will forego the politically correct name and call this bad and costly legislation by what it is. Now that the UK can have DWT, the base for all time zones is called UTC (Coordinated Universal Time or Universal Time Coordinates) but is still based at Greenwich in London. This is what you should store in your database fields. This is the value GPS satellites will generate and deep down it’s the one value you can be sure of. Your local time is usually an offset from UTC. If your country or region has DWT, then there are a couple of times a year when the local time in a field can be undefined. UTC time does not have this problem. If you divide the Earth up into 24 segments, one for each hour, then you would expect 24 different time zones to be in place. But there are more than that. Most places use a multiple of hours plus or minus UTC, so you would think plus or minus 12 hours would be enough. But there are half-hour increments of time zones. We saw a report once designed with a parameter with a UTC offset, expecting an integer value for the hours offset. Well, some places have a half hour offset including Adelaide, Darwin, Rangoon, and New Delhi. Then there is the strange situation of the Chatham Islands which is 12:45 ahead of UTC and one wonders what time they use at the base at the South Pole in Antarctica which can be in any time zone with a small step. Or the North Pole, for that matter. Further adding to the confusion, some countries span multiple time zones in an effort to stay close to the 24 segment approach while others ignore it entirely. China has one time zone covering the entire country. |
Time Zones in Crystal ReportsCrystal Reports XI included some new Time Zone features. Several of these use a Time Zone String which looks like…
The above string for New Zealand says that DWT will start on month 9 (September), Week 5, Sunday (September 28th) at 2am and finish on month 4 (April), Week 1 on a Sunday at 3am. The most important information is the offsets. The rest are just for description purposes. Using Time Zone Strings in Crystal Reports FormulasAll that sounds really cool, but not that useful in a report. Or is it? You can get the Data and Print time zones inside a formula with the DataTimeZone and PrintTimeZone functions. If someone can explain why these might be different can they let us know. CECurrentTimeZone will be the time zone on your Crystal Enterprise Server. If your network spans multiple time zones, it is possible that the user and server are in different time zones. You can then use the ShiftDateTime function to convert a date time field from one time zone to another. As it only needs the offset, you could hard code the values with
This will convert your New Zealand date times to Sydney values.
Time Zones with Dynamic DatesOur cViewSERVER report scheduler (Windows Service) includes the ability to load a date or date time parameter with a date based on the scheduler clock. It can calculate the start of the week or month and supports calendar months, 4-4-5 and 4-4-4 weekly accounting periods. By default the time on these dynamic dates is midnight (00:00) but the latest release has the ability to set each report in the schedule to a time zone. Set the time zone to 11am and all the date time parameters with a dynamic date will process with 11am as their time value. When daylight savings arrives, just change the value in the time zone setting and the reports will use the new value. We include this feature in our other report (desktop) scheduler cViewMANAGER, also. Another time zone problem solvedA Crystal Reports 10 user posted a question on Tek-Tips. The built-in function to ShiftDateTime wasn't the solution, because it's not in that version. The problem they had was a server in one time zone publishing reports for users in a different zone. We see a simple solution to this problem. If the reports are only for the other time zone, then use a formula for the print date/time of DateAdd ("h",-3 ,PrintDate + PrintTime ) This example takes the Auckland (New Zealand) time and displays the time in Sydney (Australia). If your users are in multiple time zones, then use a parameter with the number of hours they differ from the server that is processing the reports.
This article is copyrighted by Crystalkeen, Mindconnection, and Chelsea Technologies Ltd. It may be freely copied and distributed as long as the original copyright is displayed and no modifications are made to this material. Extracts are permitted. The names Crystal Reports and Seagate Info are trademarks owned by Business Objects. |