DateTime
am 19.06.2007 13:21:29 von roblowein
Hello,
Please can you point me in the right direction.
I have a table (JobMain) that holds a list of all jobs that out
engineers need to work on or have worked on.
I would like to select jobs that fall between Monday - Friday 8am to
7pm.
The tables holds a load of colums ... the two that are of interest to
me are
JobId (Primary Key) - Job Number
StartDate (Datetime datatype) - Job start date and time
regards
Rob
Re: DateTime
am 19.06.2007 13:53:43 von masri999
On Jun 19, 4:21 pm, roblowein wrote:
> Hello,
>
> Please can you point me in the right direction.
>
> I have a table (JobMain) that holds a list of all jobs that out
> engineers need to work on or have worked on.
>
> I would like to select jobs that fall between Monday - Friday 8am to
> 7pm.
>
> The tables holds a load of colums ... the two that are of interest to
> me are
>
> JobId (Primary Key) - Job Number
> StartDate (Datetime datatype) - Job start date and time
>
> regards
>
> Rob
DECLARE @startdate datetime ,@enddate datetime
SET @startdate = '2007-06-18 08:00:00' -- Monday 8 AM
SET @enddate = DATEADD(DD,4 ,DATEADD(HOUR,11,@startdate)) --
SELECT @startdate,@enddate
SELECT * FROM yourtable
WHERE StartDate BETWEEN @startdate AND enddate
Re: DateTime
am 19.06.2007 13:56:32 von Razvan Socol
Hello, Rob
Try something like this:
SELECT * FROM YourTable
WHERE DATEPART(hh,StartDate) BETWEEN 8 AND 18
AND (DATEPART(w,StartDate)+@@DATEFIRST)%7 BETWEEN 2 AND 6
Razvan
Re: DateTime
am 19.06.2007 15:45:26 von roblowein
On 19 Jun, 12:56, Razvan Socol wrote:
> Hello, Rob
>
> Try something like this:
>
> SELECT * FROM YourTable
> WHERE DATEPART(hh,StartDate) BETWEEN 8 AND 18
> AND (DATEPART(w,StartDate)+@@DATEFIRST)%7 BETWEEN 2 AND 6
>
> Razvan
Thanks to you both....
A lot of help..
Regards
Rob