PC Review


Reply
Thread Tools Rate Thread

DateTime Range. Without year ...

 
 
shapper
Guest
Posts: n/a
 
      8th Sep 2008
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
 
Reply With Quote
 
 
 
 
Eliyahu Goldin
Guest
Posts: n/a
 
      8th Sep 2008
Bring an example what you mean.

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


"shapper" <(E-Mail Removed)> wrote in message
news:2d5e3845-3861-49ec-8ed3-(E-Mail Removed)...
> 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



 
Reply With Quote
 
shapper
Guest
Posts: n/a
 
      8th Sep 2008
On Sep 8, 9:36*am, "Eliyahu Goldin"
<REMOVEALLCAPITALSeEgGoldD...@mMvVpPsS.org> wrote:
> Bring an example what you mean.
>
> --
> Eliyahu Goldin,
> Software Developer
> Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net
>
> "shapper" <mdmo...@gmail.com> wrote in message
>
> news:2d5e3845-3861-49ec-8ed3-(E-Mail Removed)...
>
> > 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

 
Reply With Quote
 
Eliyahu Goldin
Guest
Posts: n/a
 
      8th Sep 2008
Then you simply need to bring all dates to the same year:

DateTime startToTest = new DateTime(test.Year, start.Month, start.Day);
DateTime finishToTest = new DateTime(test.Year, 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" <(E-Mail Removed)> wrote in message
news:6db6e735-0384-42b1-be86-(E-Mail Removed)...
On Sep 8, 9:36 am, "Eliyahu Goldin"
<REMOVEALLCAPITALSeEgGoldD...@mMvVpPsS.org> wrote:
> Bring an example what you mean.
>
> --
> Eliyahu Goldin,
> Software Developer
> Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net
>
> "shapper" <mdmo...@gmail.com> wrote in message
>
> news:2d5e3845-3861-49ec-8ed3-(E-Mail Removed)...
>
> > 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


 
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
DateTime.MinValue.Year gives 2001 when parsed? shapper Microsoft C# .NET 2 5th Sep 2010 03:34 AM
DateTime with only Year and Day of Year O.B. Microsoft C# .NET 2 17th Oct 2007 10:07 PM
DateTime Just Month and Year =?Utf-8?B?Sm9lIFRhdmFyZXM=?= Microsoft C# .NET 2 5th Oct 2007 04:49 AM
DateTime question year, month, day from 38896 Jim Stools Microsoft C# .NET 6 29th Jun 2006 09:02 PM
parsing datetime field into month, day, year, time CJ Microsoft Access Queries 2 20th May 2004 03:23 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:57 AM.