A = 2/1/2007 (First day of current month)
B = 2/19/2007 (Current date)
C = 3/10/2007 (Some future date)
D = 1/12/2007 (Some past date)
You want to know how to calculate the following right?
B + (B-A) = C (This actually gives me 3/9/2007)
A - (B-A) = D (This actually gives me 1/14/2007)
Here's some code in C#. I hope this helps.
using System;
using System.Collections.Generic;
using System.Text;
namespace Test {
class Program {
static void Main(string[] args) {
DateTime A = new DateTime(2007, 2, 1);
DateTime B = new DateTime(2007, 2, 19);
//B = DateTime.Now; // Use this to calculate from current date
DateTime C, D;
TimeSpan DiffBminusA = (B - A);
C = B.AddDays(DiffBminusA.Days);
D = A.AddDays(-DiffBminusA.Days);
Console.Write(
"\n\n\nA==" + A.ToString()
+ "\nB==" + B.ToString()
+ "\nDiffBminusA==" + DiffBminusA.ToString()
+ "\nDiffBminusA.Days==" + DiffBminusA.Days.ToString()
+ "\nC==" + C.ToString()
+ "\nD==" + D.ToString() + "\n\n\n");
}
}
}