Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Week agenda

Author  Topic 

wiltjer
Starting Member

11 Posts

Posted - 2007-05-16 : 07:50:44
Hello,

I've made a query for an agenda.
We wil use this agenda for our employees so then can quickly see who's doing what this week.
Only now i've noticed it doesn't work quite as i hoped.
I don't see tomorrow in the result. Tomorrow being 18 may.
Can anyone tell me what i'm doing wrong?

DECLARE @startweek datetime

DECLARE @eindweek datetime

SET @startweek= (select dbo.get_week_start(getdate()+4))
SET @eindweek= (select dbo.get_week_end(getdate()+4))

select CASE datename(weekday,a.startdate)

WHEN 'Monday' THEN 'Maandag'

WHEN 'Tuesday' THEN 'Dinsdag'

WHEN 'Wednesday' THEN 'Woensdag'

WHEN 'Thursday' THEN 'Donderdag'

WHEN 'Friday' THEN 'Vrijdag'

WHEN 'Saturday' THEN 'Zaterdag'

WHEN 'Sunday' THEN 'Zondag'

END as dag,

SUBSTRING(CONVERT(varchar(30),a.startdate,120),12,5) as starttijd,

SUBSTRING(CONVERT(varchar(30),a.enddate,120),12,5) as eindtijd,

at.description AS Type,

a.description AS Omschrijving,

h.fullname,

p.description AS Schip,

hid,

'{' + CAST(a.ID AS varchar(50)) + '}' AS reqid,

ISNULL(CASE freetextfield_01
WHEN 'extern' THEN 'Extern'
WHEN 'intern' THEN 'Intern'
END, '') AS waar,

CASE WHEN DATEDIFF(dd,a.startdate,a.enddate)>1 THEN CONVERT(varchar(20),a.startdate,105)+' tm '+ CONVERT(varchar(20),a.enddate,105) ELSE CONVERT(varchar(20),a.startdate,105) END as datum

from absences a

join absencetypes at ON at.ID=a.type AND (at.UseInCalendar=1 or at.PlanHumanResource=1)

left join humres h ON h.res_id=a.EmpID

LEFT JOIN prproject p ON p.projectnr = a.projectnumber


where

a.startdate BETWEEN @startweek AND @eindweek OR

a.enddate BETWEEN @startweek AND @eindweek OR

(a.startdate<@startweek AND a.enddate>@eindweek)

order by startdate

X002548
Not Just a Number

15586 Posts

Posted - 2007-05-16 : 09:03:35
You probably don't have those days in the table

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page
   

- Advertisement -