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
 Development Tools
 ASP.NET
 Date formatting calculations!!!

Author  Topic 

reflex2dotnet
Yak Posting Veteran

99 Posts

Posted - 2007-02-19 : 11:16:42
Hi All,

My application requires lot of Date formatting calculations.
Here is my new issue, which i am trying for last two days.
Hope someone can help me in this

I have startDate as First date of current month
endDate as todays date.

eg: 2/1/2007 ---- 2/19/2007

Now what I want to calculate 3/10/2007 and 1/12/2007 from this data.
That is I want to calculate 2/19/2007 + (difference of 2/19/2007 and 2/1/2007)
2/1/2007 - (difference of 2/19/2007 and 2/1/2007)

Is this possible?

Hope I am not confusing you.

Thanks

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-02-19 : 11:23:33
[code]declare @t table (fromdt datetime, todt datetime)

insert @t
select '20070201', '20070219'

select fromdt,
todt,
dateadd(day, datediff(day, fromdt, todt), todt),
todt + (todt - fromdt)
from @t[/code]
Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -