If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Microsoft SQL Server > Minus # of months

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-09-11, 14:38
biznez biznez is offline
Registered User
 
Join Date: Nov 2011
Posts: 24
Question Minus # of months

Hi, i have a person that has been approved for 8 months
from 01/01/11 to 08/31/11

what is the query to output 6 months

and i would also like another column to show number of DAYS the person has been approved for

Thanks
Reply With Quote
  #2 (permalink)  
Old 12-09-11, 15:26
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,609
Get someone that knows SQL to take a look at your tables, it shouldn't take too long.

-PatP
__________________
In theory, theory and practice are identical. In practice, theory and practice are unrelated.
Reply With Quote
  #3 (permalink)  
Old 12-09-11, 17:45
dm1 dm1 is offline
Registered User
 
Join Date: Dec 2011
Posts: 13
Number of months:

Code:
SELECT DATEDIFF(mm, '2011-01-01', '2011-08-31');
It returns 7 months, why do you need to get 6?

Number of days:

Code:
SELECT DATEDIFF(dd, '2011-01-01', '2011-08-31');
Returns 242 days

Dmitry
--

http://www.sqlines.com - Free online SQL conversion

Last edited by dm1; 12-09-11 at 17:49.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On