SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


IIF or SWITCH Condition to use and how


IIF or SWITCH Condition to use and how

Author
Message
sanju2t
sanju2t
Grasshopper
Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)

Group: General Forum Members
Points: 15 Visits: 0
Hi,

I have a report where countrycode is a paramater and i need to show the date format as dd/MM/yyyy on basis of countrycode. Can someone help me know how can i simplify the statetment for the condition?
In Pseudo code:
If countrycode in ("AU", "NZ", "IN", "MAL")
then
endDate.Format("dd/MM/yyyy")
else
endDate.Format("MM/dd/yyyy")
end if

I need to write somewhat the same for my report (.rdl) file.

Thanks
Susheel
crashdan
crashdan
Ten Centuries
Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)

Group: General Forum Members
Points: 1030 Visits: 757
sanju2t (9/27/2012)
Hi,

I have a report where countrycode is a paramater and i need to show the date format as dd/MM/yyyy on basis of countrycode. Can someone help me know how can i simplify the statetment for the condition?
In Pseudo code:
If countrycode in ("AU", "NZ", "IN", "MAL")
then
endDate.Format("dd/MM/yyyy")
else
endDate.Format("MM/dd/yyyy")
end if

I need to write somewhat the same for my report (.rdl) file.

Thanks
Susheel


a case statement is your friend
case when countrycode in ("AU", "NZ", "IN", "MAL") then convert(varchar(12),[datecolumn],101)
else convert(varchar(12),[datecolumn],103)
end

*code may take some tweaking
D.DHAMO
D.DHAMO
SSC-Enthusiastic
SSC-Enthusiastic (121 reputation)SSC-Enthusiastic (121 reputation)SSC-Enthusiastic (121 reputation)SSC-Enthusiastic (121 reputation)SSC-Enthusiastic (121 reputation)SSC-Enthusiastic (121 reputation)SSC-Enthusiastic (121 reputation)SSC-Enthusiastic (121 reputation)

Group: General Forum Members
Points: 121 Visits: 197
Goto Expressions :

iif(fields!country.value="","",<field_name>,<field_name>Wink
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search