Home
Analytics
getHours() returns wrong hour value
PaulCooper
<p>(Version of BIRT I am using is 3.7.2)</p>
<p> </p>
<p>I have a database (SQL Server) with a record with a date time field that has a date of 01/01/1971 01:01:00 (GMT)</p>
<p> </p>
<p>I have created a report with a computed column that returns the .getHours() value from the date. Instead of getting 1 in the report I get 0.</p>
<p> </p>
<p>I have tested getUTCHours() and still get 0.</p>
<p> </p>
<p>I have proven that the date in the Database is the correct date by using CONVERT function to get the ISO8601 date which is "1971-01-01T01:01:00".</p>
<p> </p>
<p>BIRT is setup with GMT in (Window->Preferences->Report Design-> Preview) to be:</p>
<p>Locale: English (UK)</p>
<p>Time zone: GMT</p>
<p> </p>
<p>I have a report with a data set pulling that record. If view the data in the Preview Results I get "1 Jan 1971 01:01". The computed column shows 0 for the hours.</p>
<p> </p>
<p>The date displays in the report as "1 Jan 1971 00:01"</p>
<p> </p>
<p>Also I checked the time zone used by the report by adding to the bottom a data field with the follow JS in it:</p>
<p> </p>
<p>java.util.TimeZone.getDefault().toString();</p>
<p> </p>
<p>This shows:</p>
<p> </p>
<p>sun.util.calendar.ZoneInfo[id="Europe/London",offset=0,dstSavings=3600000,useDaylight=true,transitions=242,lastRule=java.util.SimpleTimeZone[id=Europe/London,offset=0,dstSavings=3600000,useDaylight=true,startYear=0,startMode=2,startMonth=2,startDay=-1,startDayOfWeek=1,startTime=3600000,startTimeMode=2,endMode=2,endMonth=9,endDay=-1,endDayOfWeek=1,endTime=3600000,endTimeMode=2]]</p>
<p> </p>
<p>which looks correct to me.</p>
<p> </p>
<p>I am completely stumped as to why I am getting 0 instead of 1 for the hour.</p>
<p> </p>
<p>Any ideas anyone?</p>
<p> </p>
<p>Regards,</p>
<p> </p>
<p>Paul Cooper</p>
<p> </p>
Find more posts tagged with
Comments
PaulCooper
<p>After some research this looks like this is actually correct as the UK Government suspended Daylight Saving between Oct 1968 and Oct 1971 leaving the UK on BST throughout this period and hence the getHours() is correct. (Being 1 year before I was born I wasn't aware that this had happened)</p>
<p> </p>
<p>Regards,</p>
<p> </p>
<p>Paul Cooper</p>