Hi!
I will get the date from now (DateTime.Now is 18.12.2003) but exact
16 years ago (18.12.1987).
when I make something like this:
//we set min. employee age to 16 years
TimeSpan minEmployeeAge = new TimeSpan(5840,0,0,0);
DateTime maxDate = DateTime.Now - minEmployeeAge;
maxDate return me the date of 22.12.1987 .
Can someone tell me how to make it to get the exact date?
regards,
gicio 11 1368
<gi***@gmx.de> wrote: I will get the date from now (DateTime.Now is 18.12.2003) but exact 16 years ago (18.12.1987).
Can someone tell me how to make it to get the exact date?
DateTime dt = DateTime.Now;
dt = dt.AddYears(-16);
// Bjorn A
DateTime.Now.Year - 16
Tamir www.tcon.co.il
<gi***@gmx.de> wrote in message news:br************@news.hansenet.net... Hi!
I will get the date from now (DateTime.Now is 18.12.2003) but exact 16 years ago (18.12.1987).
when I make something like this:
//we set min. employee age to 16 years TimeSpan minEmployeeAge = new TimeSpan(5840,0,0,0);
DateTime maxDate = DateTime.Now - minEmployeeAge; maxDate return me the date of 22.12.1987 . Can someone tell me how to make it to get the exact date?
regards,
gicio
Hi,
DateTime dt = DateTime.Now;
Console.WriteLine(dt.AddYears(-16));
--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com
<gi***@gmx.de> wrote in message news:br************@news.hansenet.net... Hi!
I will get the date from now (DateTime.Now is 18.12.2003) but exact 16 years ago (18.12.1987).
when I make something like this:
//we set min. employee age to 16 years TimeSpan minEmployeeAge = new TimeSpan(5840,0,0,0);
DateTime maxDate = DateTime.Now - minEmployeeAge; maxDate return me the date of 22.12.1987 . Can someone tell me how to make it to get the exact date?
regards,
gicio
"Bjorn Abelli" wrote: <gi***@gmx.de> wrote: I will get the date from now (DateTime.Now is 18.12.2003) but exact 16 years ago (18.12.1987).
Can someone tell me how to make it to get the exact date?
DateTime dt = DateTime.Now; dt = dt.AddYears(-16);
Or even simpler:
DateTime dt = DateTime.Now.AddYears(-16);
// Bjorn A
> I will get the date from now (DateTime.Now is 18.12.2003) but exact 16 years ago (18.12.1987).
when I make something like this: //we set min. employee age to 16 years TimeSpan minEmployeeAge = new TimeSpan(5840,0,0,0); DateTime maxDate = DateTime.Now - minEmployeeAge;
maxDate return me the date of 22.12.1987 . Can someone tell me how to make it to get the exact date?
I guess you are expecting 18.12.2003? Given that there are leap years, you
cannot simply multiply 365 by 16 and expect it to give you the same day.
How about :
DateTime maxDate = DateTime.Now.AddYears(-12);
?
--
WildHeart'2k3
You can do it much simpler by adding -16 years to the current date
DateTime maxDate = DateTime.Now.AddYears(-16);
--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
cool!!!!
thx for the very fastttttttttt help ;)
best regards,
gicio
DateTime maxDate = DateTime.Now.AddYears(-minEmployeeAge);
--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
<gi***@gmx.de> wrote in message news:br************@news.hansenet.net... Hi!
I will get the date from now (DateTime.Now is 18.12.2003) but exact 16 years ago (18.12.1987).
when I make something like this:
//we set min. employee age to 16 years TimeSpan minEmployeeAge = new TimeSpan(5840,0,0,0);
DateTime maxDate = DateTime.Now - minEmployeeAge; maxDate return me the date of 22.12.1987 . Can someone tell me how to make it to get the exact date?
regards,
gicio
Interesting question. What do you mean by "exactly 16 years". A year is
ambiguous. A sidereal year is about 365.25 days, a calendar year is
sometimes 365 days, sometimes 366 days. And leap seconds get added
sometimes. If I wanted to be really difficult I might point out that a
date is also geographically dependant.
Peter Seaman
Hi!
(in line)
"Peter Seaman" <Peter MS Seaman at StableSoftware.com> wrote in message
news:ef**************@TK2MSFTNGP10.phx.gbl... Interesting question. What do you mean by "exactly 16 years". A year is ambiguous. A sidereal year is about 365.25 days, a calendar year is sometimes 365 days, sometimes 366 days. And leap seconds get added
I know... but when you for example are born at 12.12.1950 you
celebrate your birthday every! year at 12.12 and not one year at 11.12.
and the other at 12.12.
my statemant "exactly 16 years" is not correct choosen ;)
sorry!!!
gicio
sometimes. If I wanted to be really difficult I might point out that a date is also geographically dependant.
Peter Seaman
Thanks, I was only trying to be mischevious. I often wonder when you should
celebrate your birthday - (a) On the day when your birthdate arrives in the
place you are now or (b) On the day when your birthdate arrives in the place
where you were born. These can be different!
Peter Seaman This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: John Hunter |
last post by:
>>> from datetime import date
>>> dt = date(1005,1,1)
>>> print dt.strftime('%Y')
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ValueError: year=1005 is before 1900; the...
|
by: |
last post by:
Hi!
I will get the date from now (DateTime.Now is 18.12.2003) but exact
16 years ago (18.12.1987).
when I make something like this:
//we set min. employee age to 16 years
TimeSpan...
|
by: Mark |
last post by:
Is there a way to convert a char to a DateTime without first converting to
a string and using DateTime.Parse or ParseExact? I'm trying to reuse the
char which can be reused instead of converting...
|
by: Cor Ligthert |
last post by:
Hello everybody,
Jay and Herfried are telling me every time when I use CDate that using the
datetime.parseexact is always the best way to do String to datetime
conversions. They don't tell why...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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: 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: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
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: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |