Re: Simple SQL Question
From: Brian Bushay TeamB (BBushay_at_Nmpls.com)
Date: 12/23/04
- Next message: Gonzalo Torres: "Records lost in an ADOStoredProc"
- Previous message: Jon Purvis: "Re: sql problem"
- In reply to: Don: "Simple SQL Question"
- Next in thread: J West: "Re: Simple SQL Question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 23 Dec 2004 11:00:57 -0600
>Im trying to construct a sql qry that Im going to execute via ado.
>1. How do I set a SQL qry to search dd/mm/yyyy format? ie 25/12/2004
ADO doesn't have anything to do with the date format that is dependent on the
database you use. MS SQL server bases date format on the language driver that
your login uses. If no default language driver is set US date format
(mm/dd/yyyy) is used
If you want freedom form database dateformat then use parameters in your query
for date values
>2. I would like to check that I dont have any schedule overlaps before
>making a booking.
>ie
>AccNo FromDate ToDate
>a010101 09/01/2004 12/01/2004
>
>How would I go about checking that my new schedule dates dont conflict\fall
>between these dates using a sql statement?
>
>Im sure the answers are fairly simple, Im just not thinking.
There are basically 3 possibilities you need to check for
The Date range you need to check for conflicts overlaps another date range at
the begriming of its range, at the end of its range or that an existing date
range falls with in your new date range.
So this SQL which uses parameters for the dates you are checking for will return
0 records if there is no conflict
Select * from your Table
where ( :bgnDate1 between FromDate and ToDate) or
( :endDate1 between FromDate and ToDate) or
or (FromDate between :bgnDate2 and :EndDate2)
-- Brian Bushay (TeamB) Bbushay@NMPLS.com
- Next message: Gonzalo Torres: "Records lost in an ADOStoredProc"
- Previous message: Jon Purvis: "Re: sql problem"
- In reply to: Don: "Simple SQL Question"
- Next in thread: J West: "Re: Simple SQL Question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|