Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » Hour and Minutes formating
Hour and Minutes formating [message #682173] Fri, 10 June 2011 10:53 Go to next message
Gopi  is currently offline Gopi
Messages: 10
Registered: May 2011
Junior Member
Hi ,

I need to display hours OR Hours:minutes formating based on true or false value

for example :
Timeformat ="hh:mm" then display regularhrs in hh:mm format.
or
Display regularhrs in h format.

I created a timeformat parameter and can write if statment.
How can I display REGULARHRS into hh:mm or h format.

Please suggest.
Re: Hour and Minutes formating [message #682224 is a reply to message #682173] Fri, 10 June 2011 12:26 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

Here is an example of setting date format based on a parameter. look at
the beforeFactory script. It uses a style to do this operation. I also
commented out a script on the table row oncreate that shows how to do it
if you do not want to use a style.

Jason


<?xml version="1.0" encoding="UTF-8"?>
<report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.22"
id="1">
<property name="createdBy">Eclipse BIRT Designer Version
2.6.1.v20100902 Build &lt;2.6.1.v20100915-1750></property>
<property name="units">in</property>
<method
name="beforeFactory"><![CDATA[reportContext.getDesignHandle().findStyle("table-detail").dateFormat=
params["DateFormat"].value;]]></method>
<property name="iconFile">/templates/blank_report.gif</property>
<property name="bidiLayoutOrientation">ltr</property>
<parameters>
<scalar-parameter name="DateFormat" id="55">
<property name="valueType">static</property>
<property name="dataType">string</property>
<property name="distinct">true</property>
<list-property name="selectionList">
<structure>
<property name="value">MM/dd/YYYY</property>
</structure>
<structure>
<property name="value">dd/MMM/YYYY</property>
</structure>
</list-property>
<property name="paramType">simple</property>
<property name="controlType">list-box</property>
<property name="mustMatch">true</property>
<property name="fixedOrder">true</property>
<structure name="format">
<property name="category">Unformatted</property>
</structure>
</scalar-parameter>
</parameters>
<data-sources>
<oda-data-source
extensionID="org.eclipse.birt.report.data.oda.jdbc" name="Data Source"
id="7">
<property
name="odaDriverClass">org.eclipse.birt.report.data.oda.sampledb.Driver</property>
<property name="odaURL">jdbc:classicmodels:sampledb</property>
<property name="odaUser">ClassicModels</property>
</oda-data-source>
</data-sources>
<data-sets>
<oda-data-set
extensionID="org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet"
name="Data Set" id="8">
<list-property name="columnHints">
<structure>
<property name="columnName">ORDERNUMBER</property>
<text-property
name="displayName">ORDERNUMBER</text-property>
</structure>
<structure>
<property name="columnName">ORDERDATE</property>
<text-property
name="displayName">ORDERDATE</text-property>
</structure>
<structure>
<property name="columnName">REQUIREDDATE</property>
<text-property
name="displayName">REQUIREDDATE</text-property>
</structure>
<structure>
<property name="columnName">SHIPPEDDATE</property>
<text-property
name="displayName">SHIPPEDDATE</text-property>
</structure>
<structure>
<property name="columnName">STATUS</property>
<text-property
name="displayName">STATUS</text-property>
</structure>
<structure>
<property name="columnName">COMMENTS</property>
<text-property
name="displayName">COMMENTS</text-property>
</structure>
<structure>
<property name="columnName">CUSTOMERNUMBER</property>
<text-property
name="displayName">CUSTOMERNUMBER</text-property>
</structure>
</list-property>
<structure name="cachedMetaData">
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">ORDERNUMBER</property>
<property name="dataType">integer</property>
</structure>
<structure>
<property name="position">2</property>
<property name="name">ORDERDATE</property>
<property name="dataType">date</property>
</structure>
<structure>
<property name="position">3</property>
<property name="name">REQUIREDDATE</property>
<property name="dataType">date</property>
</structure>
<structure>
<property name="position">4</property>
<property name="name">SHIPPEDDATE</property>
<property name="dataType">date</property>
</structure>
<structure>
<property name="position">5</property>
<property name="name">STATUS</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">6</property>
<property name="name">COMMENTS</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">7</property>
<property name="name">CUSTOMERNUMBER</property>
<property name="dataType">integer</property>
</structure>
</list-property>
</structure>
<property name="dataSource">Data Source</property>
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">ORDERNUMBER</property>
<property name="nativeName">ORDERNUMBER</property>
<property name="dataType">integer</property>
<property name="nativeDataType">4</property>
</structure>
<structure>
<property name="position">2</property>
<property name="name">ORDERDATE</property>
<property name="nativeName">ORDERDATE</property>
<property name="dataType">date</property>
<property name="nativeDataType">91</property>
</structure>
<structure>
<property name="position">3</property>
<property name="name">REQUIREDDATE</property>
<property name="nativeName">REQUIREDDATE</property>
<property name="dataType">date</property>
<property name="nativeDataType">91</property>
</structure>
<structure>
<property name="position">4</property>
<property name="name">SHIPPEDDATE</property>
<property name="nativeName">SHIPPEDDATE</property>
<property name="dataType">date</property>
<property name="nativeDataType">91</property>
</structure>
<structure>
<property name="position">5</property>
<property name="name">STATUS</property>
<property name="nativeName">STATUS</property>
<property name="dataType">string</property>
<property name="nativeDataType">12</property>
</structure>
<structure>
<property name="position">6</property>
<property name="name">COMMENTS</property>
<property name="nativeName">COMMENTS</property>
<property name="dataType">string</property>
<property name="nativeDataType">12</property>
</structure>
<structure>
<property name="position">7</property>
<property name="name">CUSTOMERNUMBER</property>
<property name="nativeName">CUSTOMERNUMBER</property>
<property name="dataType">integer</property>
<property name="nativeDataType">4</property>
</structure>
</list-property>
<xml-property name="queryText"><![CDATA[select *
from orders
where ordernumber < 10104]]></xml-property>
<xml-property name="designerValues"><![CDATA[<?xml
version="1.0" encoding="UTF-8"?>
<model:DesignValues
xmlns:design="http://www.eclipse.org/datatools/connectivity/oda/design"
xmlns:model="http://www.eclipse.org/birt/report/model/adapter/odaModel">
<Version>1.0</Version>
<design:ResultSets derivedMetaData="true">
<design:resultSetDefinitions>
<design:resultSetColumns>
<design:resultColumnDefinitions>
<design:attributes>
<design:name>ORDERNUMBER</design:name>
<design:position>1</design:position>
<design:nativeDataTypeCode>4</design:nativeDataTypeCode>
<design:precision>10</design:precision>
<design:scale>0</design:scale>
<design:nullability>Nullable</design:nullability>
<design:uiHints>
<design:displayName>ORDERNUMBER</design:displayName>
</design:uiHints>
</design:attributes>
<design:usageHints>
<design:label>ORDERNUMBER</design:label>
<design:formattingHints>
<design:displaySize>11</design:displaySize>
</design:formattingHints>
</design:usageHints>
</design:resultColumnDefinitions>
<design:resultColumnDefinitions>
<design:attributes>
<design:name>PRODUCTCODE</design:name>
<design:position>2</design:position>
<design:nativeDataTypeCode>12</design:nativeDataTypeCode>
<design:precision>15</design:precision>
<design:scale>0</design:scale>
<design:nullability>Nullable</design:nullability>
<design:uiHints>
<design:displayName>PRODUCTCODE</design:displayName>
</design:uiHints>
</design:attributes>
<design:usageHints>
<design:label>PRODUCTCODE</design:label>
<design:formattingHints>
<design:displaySize>15</design:displaySize>
</design:formattingHints>
</design:usageHints>
</design:resultColumnDefinitions>
<design:resultColumnDefinitions>
<design:attributes>
<design:name>QUANTITYORDERED</design:name>
<design:position>3</design:position>
<design:nativeDataTypeCode>4</design:nativeDataTypeCode>
<design:precision>10</design:precision>
<design:scale>0</design:scale>
<design:nullability>Nullable</design:nullability>
<design:uiHints>
<design:displayName>QUANTITYORDERED</design:displayName>
</design:uiHints>
</design:attributes>
<design:usageHints>
<design:label>QUANTITYORDERED</design:label>
<design:formattingHints>
<design:displaySize>11</design:displaySize>
</design:formattingHints>
</design:usageHints>
</design:resultColumnDefinitions>
<design:resultColumnDefinitions>
<design:attributes>
<design:name>PRICEEACH</design:name>
<design:position>4</design:position>
<design:nativeDataTypeCode>8</design:nativeDataTypeCode>
<design:precision>15</design:precision>
<design:scale>0</design:scale>
<design:nullability>Nullable</design:nullability>
<design:uiHints>
<design:displayName>PRICEEACH</design:displayName>
</design:uiHints>
</design:attributes>
<design:usageHints>
<design:label>PRICEEACH</design:label>
<design:formattingHints>
<design:displaySize>22</design:displaySize>
</design:formattingHints>
</design:usageHints>
</design:resultColumnDefinitions>
<design:resultColumnDefinitions>
<design:attributes>
<design:name>ORDERLINENUMBER</design:name>
<design:position>5</design:position>
<design:nativeDataTypeCode>5</design:nativeDataTypeCode>
<design:precision>5</design:precision>
<design:scale>0</design:scale>
<design:nullability>Nullable</design:nullability>
<design:uiHints>
<design:displayName>ORDERLINENUMBER</design:displayName>
</design:uiHints>
</design:attributes>
<design:usageHints>
<design:label>ORDERLINENUMBER</design:label>
<design:formattingHints>
<design:displaySize>6</design:displaySize>
</design:formattingHints>
</design:usageHints>
</design:resultColumnDefinitions>
</design:resultSetColumns>
</design:resultSetDefinitions>
</design:ResultSets>
</model:DesignValues>]]></xml-property>
</oda-data-set>
</data-sets>
<styles>
<style name="report" id="4">
<property name="fontFamily">sans-serif</property>
<property name="fontSize">10pt</property>
</style>
<style name="crosstab" id="5">
<property name="borderBottomColor">#CCCCCC</property>
<property name="borderBottomStyle">solid</property>
<property name="borderBottomWidth">1pt</property>
<property name="borderLeftColor">#CCCCCC</property>
<property name="borderLeftStyle">solid</property>
<property name="borderLeftWidth">1pt</property>
<property name="borderRightColor">#CCCCCC</property>
<property name="borderRightStyle">solid</property>
<property name="borderRightWidth">1pt</property>
<property name="borderTopColor">#CCCCCC</property>
<property name="borderTopStyle">solid</property>
<property name="borderTopWidth">1pt</property>
</style>
<style name="crosstab-cell" id="6">
<property name="borderBottomColor">#CCCCCC</property>
<property name="borderBottomStyle">solid</property>
<property name="borderBottomWidth">1pt</property>
<property name="borderLeftColor">#CCCCCC</property>
<property name="borderLeftStyle">solid</property>
<property name="borderLeftWidth">1pt</property>
<property name="borderRightColor">#CCCCCC</property>
<property name="borderRightStyle">solid</property>
<property name="borderRightWidth">1pt</property>
<property name="borderTopColor">#CCCCCC</property>
<property name="borderTopStyle">solid</property>
<property name="borderTopWidth">1pt</property>
</style>
<style name="table-header" id="56">
<property name="backgroundColor">#6078BF</property>
<property name="fontFamily">"Arial"</property>
<property name="fontSize">small</property>
<property name="fontWeight">bold</property>
<property name="color">#FFFFFF</property>
<property name="paddingTop">0px</property>
<property name="paddingLeft">0px</property>
<property name="paddingBottom">0px</property>
<property name="paddingRight">0px</property>
</style>
<style name="table-footer" id="57">
<property name="backgroundColor">#6078BF</property>
<property name="fontFamily">"Arial"</property>
<property name="fontSize">small</property>
<property name="fontWeight">bold</property>
<property name="color">#FFFFFF</property>
<property name="paddingTop">0px</property>
<property name="paddingLeft">0px</property>
<property name="paddingBottom">0px</property>
<property name="paddingRight">0px</property>
</style>
<style name="table-detail" id="58">
<property name="backgroundColor">#E6ECFF</property>
<property name="fontFamily">"Arial"</property>
<property name="fontSize">x-small</property>
<property name="fontWeight">bold</property>
<property name="color">#000080</property>
<property name="paddingTop">0px</property>
<property name="paddingLeft">0px</property>
<property name="paddingBottom">0px</property>
<property name="paddingRight">0px</property>
</style>
<style name="table-group-header-1" id="59">
<property name="backgroundColor">#809FFF</property>
<property name="fontFamily">"Arial"</property>
<property name="fontSize">small</property>
<property name="fontWeight">bold</property>
<property name="color">#FFFFFF</property>
<property name="paddingTop">0px</property>
<property name="paddingLeft">0px</property>
<property name="paddingBottom">0px</property>
<property name="paddingRight">0px</property>
</style>
<style name="table-group-footer-1" id="60">
<property name="backgroundColor">#809FFF</property>
<property name="fontFamily">"Arial"</property>
<property name="fontSize">small</property>
<property name="fontWeight">bold</property>
<property name="color">#FFFFFF</property>
<property name="paddingTop">0px</property>
<property name="paddingLeft">0px</property>
<property name="paddingBottom">0px</property>
<property name="paddingRight">0px</property>
</style>
<style name="special-header" id="61">
<property name="backgroundColor">#6078BF</property>
<property name="fontFamily">"Arial"</property>
<property name="fontSize">medium</property>
<property name="fontWeight">bold</property>
<property name="color">#FFFFFF</property>
<property name="paddingTop">0px</property>
<property name="paddingLeft">0px</property>
<property name="paddingBottom">0px</property>
<property name="paddingRight">0px</property>
</style>
<style name="crosstab-detail" id="62">
<property name="backgroundColor">#E6ECFF</property>
<property name="fontFamily">"Arial"</property>
<property name="fontSize">x-small</property>
<property name="fontWeight">bold</property>
<property name="color">#000080</property>
<property name="paddingTop">0px</property>
<property name="paddingLeft">0px</property>
<property name="paddingBottom">0px</property>
<property name="paddingRight">0px</property>
</style>
<style name="crosstab-header" id="63">
<property name="backgroundColor">#6078BF</property>
<property name="fontFamily">"Arial"</property>
<property name="fontSize">small</property>
<property name="fontWeight">bold</property>
<property name="color">#FFFFFF</property>
<property name="paddingTop">0px</property>
<property name="paddingLeft">0px</property>
<property name="paddingBottom">0px</property>
<property name="paddingRight">0px</property>
</style>
<style name="mydata" id="64">
<property name="color">orange</property>
</style>
</styles>
<page-setup>
<simple-master-page name="Simple MasterPage" id="2">
<page-footer>
<text id="3">
<property name="contentType">html</property>
<text-property
name="content"><![CDATA[<value-of>new Date()</value-of>]]></text-property>
</text>
</page-footer>
</simple-master-page>
</page-setup>
<body>
<table id="9">
<property name="dataSet">Data Set</property>
<list-property name="boundDataColumns">
<structure>
<property name="name">ORDERNUMBER</property>
<text-property
name="displayName">ORDERNUMBER</text-property>
<expression
name="expression">dataSetRow["ORDERNUMBER"]</expression>
<property name="dataType">integer</property>
</structure>
<structure>
<property name="name">ORDERDATE</property>
<text-property
name="displayName">ORDERDATE</text-property>
<expression
name="expression">dataSetRow["ORDERDATE"]</expression>
<property name="dataType">date</property>
</structure>
<structure>
<property name="name">REQUIREDDATE</property>
<text-property
name="displayName">REQUIREDDATE</text-property>
<expression
name="expression">dataSetRow["REQUIREDDATE"]</expression>
<property name="dataType">date</property>
</structure>
<structure>
<property name="name">SHIPPEDDATE</property>
<text-property
name="displayName">SHIPPEDDATE</text-property>
<expression
name="expression">dataSetRow["SHIPPEDDATE"]</expression>
<property name="dataType">date</property>
</structure>
<structure>
<property name="name">STATUS</property>
<text-property
name="displayName">STATUS</text-property>
<expression
name="expression">dataSetRow["STATUS"]</expression>
<property name="dataType">string</property>
</structure>
<structure>
<property name="name">COMMENTS</property>
<text-property
name="displayName">COMMENTS</text-property>
<expression
name="expression">dataSetRow["COMMENTS"]</expression>
<property name="dataType">string</property>
</structure>
<structure>
<property name="name">CUSTOMERNUMBER</property>
<text-property
name="displayName">CUSTOMERNUMBER</text-property>
<expression
name="expression">dataSetRow["CUSTOMERNUMBER"]</expression>
<property name="dataType">integer</property>
</structure>
</list-property>
<column id="48"/>
<column id="49"/>
<column id="50"/>
<column id="51"/>
<header>
<row id="10">
<cell id="11">
<label id="12">
<text-property
name="text">ORDERNUMBER</text-property>
</label>
</cell>
<cell id="13">
<label id="14">
<text-property
name="text">ORDERDATE</text-property>
</label>
</cell>
<cell id="15">
<label id="16">
<text-property
name="text">REQUIREDDATE</text-property>
</label>
</cell>
<cell id="17">
<label id="18">
<text-property
name="text">SHIPPEDDATE</text-property>
</label>
</cell>
</row>
</header>
<detail>
<row id="25">
<cell id="26">
<data id="27">
<property
name="resultSetColumn">ORDERNUMBER</property>
</data>
</cell>
<cell id="28">
<data id="29">
<method
name="onCreate"><![CDATA[//this.getStyle().dateFormat =
params["DateFormat"].value;]]></method>
<property
name="resultSetColumn">ORDERDATE</property>
</data>
</cell>
<cell id="30">
<data id="31">
<property
name="resultSetColumn">REQUIREDDATE</property>
</data>
</cell>
<cell id="32">
<data id="33">
<property
name="resultSetColumn">SHIPPEDDATE</property>
</data>
</cell>
</row>
</detail>
<footer>
<row id="40">
<cell id="41"/>
<cell id="42"/>
<cell id="43"/>
<cell id="44"/>
</row>
</footer>
</table>
</body>
</report>


On 6/10/2011 10:53 AM, Gopi wrote:
> Hi ,
>
> I need to display hours OR Hours:minutes formating based on true or
> false value
>
> for example :
> Timeformat ="hh:mm" then display regularhrs in hh:mm format.
> or Display regularhrs in h format.
>
> I created a timeformat parameter and can write if statment.
> How can I display REGULARHRS into hh:mm or h format.
>
> Please suggest.
Re: Hour and Minutes formating [message #682240 is a reply to message #682224] Fri, 10 June 2011 13:23 Go to previous messageGo to next message
Gopi  is currently offline Gopi
Messages: 10
Registered: May 2011
Junior Member
Hello Jason,

Thank you for qucik reply."REGULARHRS " is declared as float.
Database stores it as HOURS:MINUTES .
I just have to separate hours from HOURS:MINUTES when user selects timeformat(parameter) =TRUE"
else
Regular hours should dispaly in hours:minutes (fixed ) format.

Re: Hour and Minutes formating [message #682250 is a reply to message #682240] Fri, 10 June 2011 13:36 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

What does the value look like when retrieved. Can you give an example?

Jason

On 6/10/2011 1:23 PM, Gopi wrote:
> Hello Jason,
>
> Thank you for qucik reply."REGULARHRS " is declared as float.
> Database stores it as HOURS:MINUTES . I just have to separate hours from
> HOURS:MINUTES when user selects timeformat(parameter) =TRUE"
> else
> Regular hours should dispaly in hours:minutes (fixed ) format.
>
>
Re: Hour and Minutes formating [message #682257 is a reply to message #682250] Fri, 10 June 2011 13:54 Go to previous messageGo to next message
Gopi  is currently offline Gopi
Messages: 10
Registered: May 2011
Junior Member
RegularHrs: 4:13333(4 hours :1333 minutes)
When Timeformat(parameter) ="True" then
{
Regularhrs = 4
}
else
{
Regularhrs = 4.13
}

Thank you for your help.Please let me know if this example is not clear.
Re: Hour and Minutes formating [message #682320 is a reply to message #682257] Fri, 10 June 2011 16:02 Go to previous message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

When you preview the dataset a float comes back with 4: in it?

Jason

On 6/10/2011 1:54 PM, Gopi wrote:
> RegularHrs: 4:13333(4 hours :1333 minutes)
> When Timeformat(parameter) ="True" then
> {
> Regularhrs = 4 }
> else
> {
> Regularhrs = 4.13 }
>
> Thank you for your help.Please let me know if this example is not clear.
>
Previous Topic:Get windows Username
Next Topic:relative path reference in html?
Goto Forum:
  


Current Time: Wed Jul 30 21:24:50 EDT 2014

Powered by FUDForum. Page generated in 0.02108 seconds