Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
Old 01-23-2006, 09:13 AM Dates
Skilled Talker

Posts: 95
Trades: 0
Hi, I'm looking for help.

I have a form that writes two dates to a database a Start Date and End date.

I want to be able to check the dates on the form dont alredy exist in the databse.

Ie if the databse holds the start date of 23/06/2006 and the end date of 29/06/06

I dont want the user on the form to be able to enter a date that is the same or falls between those date.

I know how to check a data against a date but not against a date range
higginbt is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-23-2006, 10:11 AM
Minaki's Avatar
Defies a Status

Posts: 1,626
Location: Guildford, UK
Trades: 0
What you can do is check if the user entered start date is between the two dates in the database and then do the same with the end date that the user entered. This will tell you if there's any overlap.
Code:
SELECT Count(*) FROM MyTable WHERE (@UserStartDate > StartDate AND @UserStartDate < EndDate) OR (@UserEndDate > StartDate AND @UserEndDate < EndDate)
will return the number of records where @UserStartDate or @UserEndDate falls between the StartDate and EndDate fields. (i.e. 0 if there's no overlap)
__________________
Minaki Serinde MCP
"Wow, Linux is nearly on-par with Windows ME!"

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Last edited by Minaki; 01-23-2006 at 10:16 AM..
Minaki is offline
Reply With Quote
View Public Profile Visit Minaki's homepage!
 
Old 01-23-2006, 10:33 AM
Skilled Talker

Posts: 95
Trades: 0
I'd just come up with my own method similar to yours but a lot more long winded. Thanks will try both methods out.
higginbt is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Dates
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.27674 seconds with 12 queries