Monthly Archives: April 2009

PostgreSql: Getting Date in Different Format and group by month

Select  to_char(date_inserted, ‘YYYYMM’) as year_month, to_char(date_inserted, ‘YYYY’) as year_string, to_char(date_inserted, ‘month’) as month_string from myTable group by year_month order by year_month; In the above example, year_month value is displayed as 200804, here 2008 is year and 04 is month. year_string value is displayed as 2008, its a year. month_string value is displayed as april, its [...]

iReport: Applying Condition depending on the parameter value passed

i had the problem like i want to keep the where condition depending on the value of parameter is pass. i tried different things, and final got through with following solution. select * from deptartment where (CASE WHEN $P{param_dept_codice} = -1 THEN true ELSE dept_codice = $P{param_dept_codice} END) above query displays all the records from [...]

iReport: Condition Expression ?:

in ireports we can write condional expression depending on the parameter passed. here is the example. $P{param_codice}.equals( new java.lang.Long(-1) ) ? “” : $F{field_descrizione}

iReport: Displaying current date and time

To display current date and time, you can add a Text field component to design interface. set the following properties: Expression class :  java.util.Date Text Field Expression :  new Date() Pattern: dd MMMMM yyyy h.mm a

Retrieving ip address from connectionstring of app.config file

Here is an example of  retrieving ip address from connectionstring of app.config file. ==> you must referece system.Configuration dll to your project. =========================== imporst system.configuration Dim connStr, serverIP As String Dim startIndex, endIndex As Integer serverIP = “” Try connStr = ConfigurationManager.ConnectionStrings(“MyConnectionString”).ConnectionString startIndex = connStr.IndexOf(“server=”) + 7     ‘ (server=) has 7 characters in it endIndex [...]

CASE…WHEN…END

in Postgre SQL, we have CASE…WHEN…END. syntax : CASE WHEN condition1 THEN value1 WHEN condition2 THEN value2 WHEN condition3 THEN value3 ELSE value4 END Example : SELECT    emp_codice, emp_descrizione, emp_dept, (CASE WHEN emp_dept = ‘S’ THEN  ‘SALES’ WHEN emp_dept = ‘M’ THEN ‘MARKETTING’ ELSE ‘GENERAL’ END) as emp_dept_desc FROM        public.tbl_emp

Follow

Get every new post delivered to your Inbox.