Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 subtracting 2 different months in 2 columns

Author  Topic 

marcusstar10
Starting Member

14 Posts

Posted - 2011-03-10 : 08:54:59
Is there anyway too subtract dates like this?

select
agent_id,
datediff(day,activation_date, deactivation_date) as Mission Durations
from missions
order by agent_id

the activation date and deavtivation date are columns with dates recorded in them

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2011-03-10 : 09:01:07
[code]select
mission_id,
mission_date,
dateadd(mm,2,mission_date) as deadline
from
missions
order by
mission_id[/code]
Go to Top of Page

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2011-03-10 : 09:02:55
May be not ? I didn't quite understand your requirement. What I wrote is to simply display the deadline for each mission assuming the deadline is two months from the mission_date.

If something else, can you describe it?
Go to Top of Page

marcusstar10
Starting Member

14 Posts

Posted - 2011-03-10 : 09:17:46
Thanks your assistance really helped, i just changed the (mm,2,mission_date)syntax to what i had previously
Go to Top of Page

marcusstar10
Starting Member

14 Posts

Posted - 2011-03-10 : 09:28:31
Is there anyway too subtract dates like this?

select
agent_id,
datediff(day,activation_date, deactivation_date) as Mission Durations
from missions
order by agent_id

the activation date and deavtivation date are columns with dates recorded in them
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-03-10 : 09:58:59
quote:
Originally posted by marcusstar10

Is there anyway too subtract dates like this?

select
agent_id,
datediff(day,activation_date, deactivation_date) as Mission Durations
from missions
order by agent_id

the activation date and deavtivation date are columns with dates recorded in them


You are asking answer for the same question. Didn't previous answer help you? Post some sample data with expected result

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -