Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Try to CONVERT a float to a varchar

Status
Not open for further replies.

tomr1555

Programmer
Apr 15, 2011
3
US
User wants the word ' hrs' placed at the end of a float variable and I cannot figure out how to do this. WEEK1_cHours is float so I cannot place the hrs onto the amount.

WEEK1_BENEFITDAYS =
CASE WHEN PenAgencyName = 'NIA'
AND WEEK1_SICK > PenSickWeeksPd THEN 0
WHEN PenAgencyName = 'NIA'
AND WEEK1_OJI > PenOJIWeeksPd THEN 0
WHEN EMP_STATUS_1 = '39'
AND HWAgencyName IN ( ' CS' )
AND WEEK1_cHours < 24
THEN WEEK1_cHours
WHEN EMP_STATUS_1 = '02'
AND HWAgencyName IN ( ' CS' )
AND wrpTransfer.UNION_LOCAL <> ''
AND WEEK1_cHours < 24 THEN WEEK1_cHours
ELSE WEEK1_cUnits + WEEK1_pUnits END,

Any help would be appreciated.
 
Code:
WEEK1_BENEFITDAYS = [red]convert(varchar,[/red] 
	CASE 
	WHEN PenAgencyName = 'NIA' AND WEEK1_SICK > PenSickWeeksPd THEN 0
	WHEN PenAgencyName = 'NIA' AND WEEK1_OJI > PenOJIWeeksPd THEN 0
	WHEN EMP_STATUS_1 = '39' AND HWAgencyName IN ( ' CS' ) AND WEEK1_cHours < 24 THEN WEEK1_cHours
	WHEN EMP_STATUS_1 = '02' AND HWAgencyName IN ( ' CS' ) AND wrpTransfer.UNION_LOCAL <> '' AND WEEK1_cHours < 24 THEN WEEK1_cHours 
ELSE WEEK1_cUnits + WEEK1_pUnits END[red]) + ' hrs'[/red],




Mark

"You guys pair up in groups of three, then line up in a circle."
- Bill Peterson, a Florida State football coach
 
Thanks Mark..

Only the two statements listed below need the hrs added to the amt.

WHEN EMP_STATUS_1 = '39' AND HWAgencyName IN ( ' CS' ) AND WEEK1_cHours < 24 THEN WEEK1_cHours

WHEN EMP_STATUS_1 = '02' AND HWAgencyName IN ( ' CS' ) AND wrpTransfer.UNION_LOCAL <> '' AND WEEK1_cHours < 24 THEN WEEK1_cHours
 


The convert statement will convert the final computation of all your case logic. WEEK1_BENEFITDAYS can only equal one value, regardless of the number of case when-then-else clauses. That value will be converted to a string with ' hrs' appended.


Mark

"You guys pair up in groups of three, then line up in a circle."
- Bill Peterson, a Florida State football coach
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top