How to convert years into months

In my database i have two fields, period and term, sometimes period is right, but sometimes not

if period has months, then leave it
but if period has something ele in it then that needs to be converted into months etc years,days,weeks

for example
Period             Term
years               3

so, in this case term needs to be 36

any ideas....

fahVBAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
BrandonGalderisiConnect With a Mentor Commented:
no points please.

Just make sure you put 'years' or 'months' in quotes since it's a string.

select case period when 'years' then term * 12
when 'Months' then term
end
from table

0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
if period = days, and term = 1 for example, what do you want to be the output?

meanwhile, check out the CASE statement...
0
 
chapmandewConnect With a Mentor Commented:
some sort of case statement should suffice:

select case period when years then term * 12
when days then term /31
end
from table

There are more calculations to work in there, but this shoudl get you started on one way to do this.  Maybe put the case in a function to use later.
0
Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

 
fahVBAuthor Commented:
if period = days, and term = 1------this never happens
0
 
fahVBAuthor Commented:
angelIII, there is no case stmt
0
 
fahVBAuthor Commented:
How about weeks and semimonths
0
 
BrandonGalderisiCommented:
Trying to translate everything into a larger unit of measure is tough.  How many months is 7 weeks?  2?  What if it spans from end of april to the beginning of june?  Is that still 2?
0
 
fahVBAuthor Commented:
Thank you
0
All Courses

From novice to tech pro — start learning today.