473,799 Members | 3,382 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DateTime Range. Without year ...

Hello,

I am checking a DateTime variable to check if in range: low <
MyDateTime < high.

However, I know need do the same but not care about the year. Can I do
this?

Thanks,
Miguel
Sep 8 '08 #1
3 1532
Bring an example what you mean.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"shapper" <md*****@gmail. comwrote in message
news:2d******** *************** ***********@b1g 2000hsg.googleg roups.com...
Hello,

I am checking a DateTime variable to check if in range: low <
MyDateTime < high.

However, I know need do the same but not care about the year. Can I do
this?

Thanks,
Miguel

Sep 8 '08 #2
On Sep 8, 9:36*am, "Eliyahu Goldin"
<REMOVEALLCAPIT ALSeEgGoldD...@ mMvVpPsS.orgwro te:
Bring an example what you mean.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net

"shapper" <mdmo...@gmail. comwrote in message

news:2d******** *************** ***********@b1g 2000hsg.googleg roups.com...
Hello,
I am checking a DateTime variable to check if in range: low <
MyDateTime < high.
However, I know need do the same but not care about the year. Can I do
this?
Thanks,
Miguel
Well, consider the following two dates:

Start:
2007-09-08 11:29:50

Finish:
2007-10-12 12:30:20

Then the test date:
2008-09-22 08:29:50

The test date is between the other two dates if you don't consider the
year. That is what I need to test.

Thanks,
Miguel

Sep 8 '08 #3
Then you simply need to bring all dates to the same year:

DateTime startToTest = new DateTime(test.Y ear, start.Month, start.Day);
DateTime finishToTest = new DateTime(test.Y ear, finish.Month, finish.Day);

and check if startToTest < test < finishToTest.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"shapper" <md*****@gmail. comwrote in message
news:6d******** *************** ***********@f36 g2000hsa.google groups.com...
On Sep 8, 9:36 am, "Eliyahu Goldin"
<REMOVEALLCAPIT ALSeEgGoldD...@ mMvVpPsS.orgwro te:
Bring an example what you mean.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net

"shapper" <mdmo...@gmail. comwrote in message

news:2d******** *************** ***********@b1g 2000hsg.googleg roups.com...
Hello,
I am checking a DateTime variable to check if in range: low <
MyDateTime < high.
However, I know need do the same but not care about the year. Can I do
this?
Thanks,
Miguel
Well, consider the following two dates:

Start:
2007-09-08 11:29:50

Finish:
2007-10-12 12:30:20

Then the test date:
2008-09-22 08:29:50

The test date is between the other two dates if you don't consider the
year. That is what I need to test.

Thanks,
Miguel
Sep 8 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
9348
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 datetime strftime() methods require year >= 1900 Does anyone know of a datetime string formatter that can handles strftime format strings over the full range that datetime objects support?
5
3951
by: Abdolhosein Vakilzadeh Ebrahimi | last post by:
Is there any way to construct a System.DateTime which doesn't check year, month and day to be in correct range== no validation? Thanks A.V.Ebrahimi
9
1355
by: Tony Van | last post by:
They're driving me nuts, especially with the Datareader. There are times when I want to pass a null date on to a date variable and I have to cast the null as a date!!!??? I'm wondering if I should just forget it and dates and times as a string in the database table. Anyone wrestle with this decision?
29
2796
by: dyork | last post by:
When getting data from a database using the dbapi and an SQL query, how do you in general round trip the data? Especially date-time? An SQL datetime column translates nicely into a Python datetime (surprise), which then translates into a string like '2005-08-03 07:32:48'. No problem with that -- all works quite nicely, until you try to put data back the other way.
6
38948
by: Brandon | last post by:
I'm using PHP with MySQL 4.x and was having trouble converting a datetime from MySQL into a formatted string until I ran across this solution that converts a YYYY-MM-DD HH:MM:SS string into a Unix-style timestamp and then formats it. $timestamp = "2005-04-06 15:43:34"; $time = strtotime($timestamp); print date('Y-m-d \a\t H:i', $time)."\n"; However, it seems kind of counter productive. After all, aren't people
5
5459
by: mroeloffs | last post by:
Hi I have a time in microseconds, for example 0x8C905CBA7F84AF4. I want this to a normal view in hh:mm:ss DD:MM:YYYY. I tried with datetime, but it only takes a max of 1000000 microseconds is there another solution?
0
16512
yasirmturk
by: yasirmturk | last post by:
Standard Date and Time Functions The essential date and time functions that every SQL Server database should have to ensure that you can easily manipulate dates and times without the need for any formatting considerations at all. They are simple, easy, and brief and you should use them any time you need to incorporate any date literals or date math in your T-SQL code. create function DateOnly(@DateTime DateTime) -- Returns @DateTime...
14
350
by: shapper | last post by:
Hello, I have two nullable DateTime: begin and end. I need to find the range, in month, between both variables. If for some reason, for example begin is null, it is not possible to calculate the range then I want to define the range as 1 month. How can I do this?
0
9688
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9544
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10490
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10259
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10030
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9077
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7570
isladogs
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
2
3761
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2941
bsmnconsultancy
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.