Monday, September 30, 2013

SSRS 2008 R2 Snippets

FILTERS

?


Expression Date Time in M, d yyyy hh:mm AM/PM format =MonthName(Month(Fields!Most_Recent_Inspection_Date.Value),false)
& " " &
Day(Fields!Most_Recent_Inspection_Date.Value)
& ", " &
Year(Fields!Most_Recent_Inspection_Date.Value)
& " at " &
Switch(
Hour(Fields!Most_Recent_Inspection_Date.Value)=12,Hour(Fields!Most_Recent_Inspection_Date.Value) & ":" & IIF(Minute(Fields!Most_Recent_Inspection_Date.Value)<10,"0" & Minute(Fields!Most_Recent_Inspection_Date.Value) & " PM",Minute(Fields!Most_Recent_Inspection_Date.Value) & " PM"),
Hour(Fields!Most_Recent_Inspection_Date.Value)=0,"12:" & IIF(Minute(Fields!Most_Recent_Inspection_Date.Value)<10,"0" & Minute(Fields!Most_Recent_Inspection_Date.Value) & " AM",Minute(Fields!Most_Recent_Inspection_Date.Value) & " AM"),
Hour(Fields!Most_Recent_Inspection_Date.Value)>12,Hour(Fields!Most_Recent_Inspection_Date.Value)-12 & ":" & IIF(Minute(Fields!Most_Recent_Inspection_Date.Value)<10,"0" & Minute(Fields!Most_Recent_Inspection_Date.Value) & " PM",Minute(Fields!Most_Recent_Inspection_Date.Value) & " PM"),
Hour(Fields!Most_Recent_Inspection_Date.Value)<12,Hour(Fields!Most_Recent_Inspection_Date.Value) & ":" & IIF(Minute(Fields!Most_Recent_Inspection_Date.Value)<10,"0" & Minute(Fields!Most_Recent_Inspection_Date.Value) & " AM",Minute(Fields!Most_Recent_Inspection_Date.Value) & " AM"))



Owner Full Name
COALESCE(CASE
WHEN isnull(dbo.B3OWNERS.B1_OWNER_FNAME, '') + isnull(B3OWNERS.B1_OWNER_MNAME, '') + isnull(B3OWNERS.B1_OWNER_LNAME, '') <> ''
THEN CASE
WHEN isnull(B3OWNERS.B1_OWNER_MNAME, '') <> ''
THEN CASE
WHEN ISNULL(dbo.B3OWNERS.B1_OWNER_TITLE, '') <> ''
THEN dbo.B3OWNERS.B1_OWNER_TITLE
ELSE ''
END + B3OWNERS.B1_OWNER_FNAME + ' ' + B3OWNERS.B1_OWNER_MNAME + ' ' + B3OWNERS.B1_OWNER_LNAME
ELSE B3OWNERS.B1_OWNER_FNAME + ' ' + B3OWNERS.B1_OWNER_LNAME
END
ELSE NULL
END, CASE
WHEN isnull(B3OWNERS.B1_OWNER_FULL_NAME, '') <> ''
THEN B3OWNERS.B1_OWNER_FULL_NAME
ELSE NULL
END) AS 'Owner Full Name'

Contact Full Name
COALESCE(CASE
WHEN isnull(dbo.B3CONTACT.B1_FNAME, '') + isnull(B3CONTACT.B1_MNAME, '') + isnull(B3CONTACT.B1_LNAME, '') <> ''
THEN CASE
WHEN isnull(B3CONTACT.B1_MNAME, '') <> ''
THEN CASE
WHEN ISNULL(dbo.B3CONTACT.B1_TITLE, '') <> ''
THEN dbo.B3CONTACT.B1_TITLE
ELSE ''
END + B3CONTACT.B1_FNAME + ' ' + B3CONTACT.B1_MNAME + ' ' + B3CONTACT.B1_LNAME
ELSE B3CONTACT.B1_FNAME + ' ' + B3CONTACT.B1_LNAME
END
ELSE NULL
END, CASE
WHEN isnull(B3CONTACT.B1_FULL_NAME, '') <> ''
THEN CASE
WHEN ISNULL(dbo.B3CONTACT.B1_TITLE, '') <> ''
THEN dbo.B3CONTACT.B1_TITLE
ELSE ''
END + B3CONTACT.B1_FULL_NAME
ELSE NULL
END, CASE
WHEN ISNULL(dbo.B3CONTACT.B1_BUSINESS_NAME,'') <> '' THEN dbo.B3CONTACT.B1_BUSINESS_NAME ELSE NULL END) AS 'Contact Full Name'

SSRS 2008 R2 Snippets

Today's Date
Inside an Internal Parameter as a Default Value:
=MonthName(Month(Now()),false) & " " & Day(Now()) & ", " & Year(Now())

Format Currency
=Format(10000 - First(Fields!Fee_Total.Value, "HousingDeptWFee"),"C")

Sunday, September 1, 2013

My Solution to the Coconuts and Monkey Problem

This applies to the problem located here http://orion.math.iastate.edu/burkardt/puzzles/coconut_solution.html.  I guess I could have made the function recursive but I want to move onto other things.  This was done in java.

public class main {
public static void main(String[] args) {
// TODO Auto-generated method stub
float total = 0;
math_functions mf = new math_functions();
for(float x=20000 ; x>0 ; x--){
total = (mf.coconuts(mf.coconuts(mf.coconuts(mf.coconuts(mf.coconuts(mf.coconuts(x)))))));
if(total%1 == 0 && total > 0){
System.out.println("total left " + total + " starting coconuts " + (x));
//break;
}
}
}
public float coconuts(float x) { float total = (float)(4*((x/5)-.2)); if(total%1 != 0){ return 0; }else{ return total; } }