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. 5 1757
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
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.
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" <ch******@yahoo.com> wrote in message news:eF**************@TK2MSFTNGP09.phx.gbl... 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.
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();
whoops - read it too fast. disregard my response. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Gerrit Holl |
last post by:
Posted with permission from the author.
I have some comments on this PEP, see the (coming) followup to this message.
PEP: 321
Title: Date/Time Parsing and Formatting
Version: $Revision: 1.3 $...
|
by: Gord |
last post by:
Many scripts and calendars call client side system time in order to
make presentations.
However, the client's time may be improperly set, if set at all,
and/or the relevant time may be from...
|
by: Jim in Arizona |
last post by:
I have a gridview that's being populated from an access db query. The
problem I'm having is that the date/time fields in access that are
populating the gridview are showing both date and time, when...
|
by: Umesh |
last post by:
i want to calculate the time required to execute a program. Also i
want to calcute the time remaining for the execution of the program.
how can i do that?
pl mention some good websites for...
|
by: krishnakant Mane |
last post by:
hello,
I am strangely confused with a date calculation problem.
the point is that I want to calculate difference in two dates in days.
there are two aspects to this problem.
firstly, I can't get...
| |
by: rodneyeid |
last post by:
Hi,
I have an attendance machine which saves records in an Access Database in the following format : UserID DATE/TIME Checktype
where if checktype is 0 then its check in and if it is 1 then it...
|
by: Brian |
last post by:
I have a 2000/2002 Access db that I use to collect and store my exercisetime using a form to enter. I wanted to see a summary of the total timefor each exercise so I have a subform that does this....
|
by: Nathan Sokalski |
last post by:
When determining whether a String can be converted to a DateTime, you can
use the IsDate() method. However, I would also like to know whether the
string is a date, a time, or both a date and a...
|
by: ahmurad |
last post by:
Dear Brothers,
I am struggling the following four Date-Time type values which were inputted into MYSQL database in different tables. As
MYSQL Default Time Format: YYYY-MM-DD HH:MM:SS, So I used...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |