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 2023
<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: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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,...
| |