Hi everybody,

I'm wondering is there a way to check wither a dateTime is selected within particular period.

Let me give a e.g:

suppose I've
date1 = "07/18/2010 08:00"
date2 = "07/18/2010 10:30"

date1 and date2 represent a period of time from 8 to 10 in 18/07.

I want to check that the new entered period date3 and date4 are not intersecting the period above.

e.g.
date3 = "07/18/2010 07:00"
date4 = "07/18/2010 011:00"

I'm working on asp.net VB.NET

Could PLZ hint me how to solve it?

Recommended Answers

All 3 Replies

If you are going to check this at the time of inserting row in database then you can check it by firing SQL query and see if it's returning any row that means you can't insert those newly (date3, date4) in database. your select query looks like below

Select * from yourtable where StartDate >= date3 and EndDate <= date4

try this and let us know :-)

Hi everybody,

I'm wondering is there a way to check wither a dateTime is selected within particular period.

Let me give a e.g:

suppose I've
date1 = "07/18/2010 08:00"
date2 = "07/18/2010 10:30"

date1 and date2 represent a period of time from 8 to 10 in 18/07.

I want to check that the new entered period date3 and date4 are not intersecting the period above.

e.g.
date3 = "07/18/2010 07:00"
date4 = "07/18/2010 011:00"

I'm working on asp.net VB.NET

Could PLZ hint me how to solve it?

rohand my friend your suggestion is 99.99% correct..

but wot if user selects the same start Date and same End Date

wots going to happen.. ?

thanks dnanetwork. But i think it will work in those case also. But still i am not sure.. But one thing can you please let us know the proper code or solutions if you find ? thanks a lot.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.