Solved

How to convert years into months

Posted on 2008-10-01
8
743 Views
Last Modified: 2012-06-21
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....

0
Comment
Question by:fahVB
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 143

Expert Comment

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

meanwhile, check out the CASE statement...
0
 
LVL 60

Assisted Solution

by:chapmandew
chapmandew earned 240 total points
ID: 22618742
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
 
LVL 39

Accepted Solution

by:
BrandonGalderisi earned 260 total points
ID: 22618766
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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 

Author Comment

by:fahVB
ID: 22618872
if period = days, and term = 1------this never happens
0
 

Author Comment

by:fahVB
ID: 22618887
angelIII, there is no case stmt
0
 

Author Comment

by:fahVB
ID: 22618918
How about weeks and semimonths
0
 
LVL 39

Expert Comment

by:BrandonGalderisi
ID: 22618973
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
 

Author Closing Comment

by:fahVB
ID: 31502156
Thank you
0

Featured Post

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question