Topic
• Latest Post - ‏2013-10-24T18:04:58Z by OpherB
LouLou
7 Posts

# Pinned topic Changing different time periods into days

‏2013-10-24T15:40:18Z |

I have a field "Time Period" , the options are "Months", "Weeks", "Days", Hours.  In another column is a number for instance if it says "Month" and the "number column" indicates 6, I want to change the 6 months to days.  I would use the average number of days per month as 30.4375.

I need the syntax for the calculation:  If [Time Period] = "Month" then [Number Field] *30.4375

If [Time Period] = "Week" then [Number Field] *7

If [Time Period] = "Day" then [Number Field] * 1

If [Time Period] = "hours" then [Number Field]  * 1/24

I just need a clean calculation that has the proper syntax.

Instead of "IF" a "Case" statement is preferred.

Thanks for any help you can provide.

• OpherB
1273 Posts

#### Re: Changing different time periods into days

‏2013-10-24T18:04:58Z

I think a Simple Case statement will work fine:

CASE [Time Period]
WHEN 'Month' THEN ([Number Field] *30.4375)
WHEN 'Week' THEN (Number Field] *7)
WHEN 'Day' THEN (Number Field] *1)
WHEN 'Hours' THEN (Number Field] * 1/24)
ELSE 0
END

Good luck,
Opher