PC Review


Reply
Thread Tools Rate Thread

calculating date time

 
 
Carlos
Guest
Posts: n/a
 
      27th Sep 2005
Hi all,

I have used the datetime class, but I just came up with a situation
that need to have some advise. If I now how much time have passed,
can I know the original date?. Lets say that I know that have passed
2 weeks and 3 days after any given event. How can I know the original
date of the event?

Thanks in advance.


Carlos.


 
Reply With Quote
 
 
 
 
Brian P
Guest
Posts: n/a
 
      27th Sep 2005

If you know that the difference between two dates is 17 days, then, so
long as you know one of the days, you can find the other.

If Day2 - Day1 = 17 Days, then Day1 + 17 = Day 2.

But, if all you known is 17 days, but you don't know when that 17 days
stopped, or started, then I don't see how you can get any more
information than that.

--Brian


Carlos wrote:
> Hi all,
>
> I have used the datetime class, but I just came up with a situation
> that need to have some advise. If I now how much time have passed,
> can I know the original date?. Lets say that I know that have passed
> 2 weeks and 3 days after any given event. How can I know the original
> date of the event?
>
> Thanks in advance.
>
>
> Carlos.
>
>

 
Reply With Quote
 
Rob Schieber
Guest
Posts: n/a
 
      27th Sep 2005
Carlos wrote:
> Hi all,
>
> I have used the datetime class, but I just came up with a situation
> that need to have some advise. If I now how much time have passed,
> can I know the original date?. Lets say that I know that have passed
> 2 weeks and 3 days after any given event. How can I know the original
> date of the event?
>
> Thanks in advance.
>
>
> Carlos.
>
>


Hi Carlos,

Use the timespan class.

2 weeks, 3 days = 17 days,

DateTime origDate = DateTime.Now.Subtract(new TimeSpan(17, 0,0,0,0));

--
Rob Schieber
 
Reply With Quote
 
Dave
Guest
Posts: n/a
 
      27th Sep 2005
You need some frame of reference first. If 2 weeks and 3 days have passed until NOW (or a specified date), then you can get the
original date.

TimeSpan span = TimeSpan.FromDays(17D); // 17 days (D = double modifier)
DateTime now = DateTime.Now;

DateTime start = now.Subtract(span);

--
Dave Sexton
dave@www..jwaonline..com
-----------------------------------------------------------------------
"Carlos" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> Hi all,
>
> I have used the datetime class, but I just came up with a situation
> that need to have some advise. If I now how much time have passed,
> can I know the original date?. Lets say that I know that have passed
> 2 weeks and 3 days after any given event. How can I know the original
> date of the event?
>
> Thanks in advance.
>
>
> Carlos.
>



 
Reply With Quote
 
jeremiah johnson
Guest
Posts: n/a
 
      27th Sep 2005
Carlos wrote:
> Hi all,
>
> I have used the datetime class, but I just came up with a situation
> that need to have some advise. If I now how much time have passed,
> can I know the original date?. Lets say that I know that have passed
> 2 weeks and 3 days after any given event. How can I know the original
> date of the event?
>
> Thanks in advance.
> Carlos.


DateTime then = DateTime.Now;

.... // stuff happens here.

DateTime now = DateTime.Now;

TimeSpan ts = now - then;

Console.WriteLine(ts.Milliseconds);
// or ts.Seconds, or ts.Minutes, or whatever.

--
jeremiah();
 
Reply With Quote
 
jeremiah johnson
Guest
Posts: n/a
 
      27th Sep 2005
whoops - read it too fast. disregard my response.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calculating Time with Date/Time checking in formula cmatera Microsoft Excel Worksheet Functions 2 11th Aug 2008 01:38 PM
Calculating Difference Between Start Date & Time And End Date & Ti =?Utf-8?B?U2Ftd2Fy?= Microsoft Excel Misc 2 19th Dec 2005 12:42 PM
Calculating days & time left from start date/time to end date/time =?Utf-8?B?bWFyaWU=?= Microsoft Excel Worksheet Functions 7 7th Dec 2005 02:36 PM
Calculating effective time from start/end date+time Stefan Stridh Microsoft Excel Worksheet Functions 8 27th Nov 2004 03:50 PM
calculating the finish time/date from the start time/date swiss tony Microsoft Excel Worksheet Functions 1 21st Oct 2003 01:24 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:48 AM.