MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 17th, 2012, 08:02 PM
narrokk narrokk is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 31 narrokk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 42 sec
Reputation Power: 1
Talking Week range to single day

ok guys, i want to hear what you would do in my current situation. i am currently fixing a crystal report, which its source is a stored procedure in SQL Server 2000. The problem here is this.

if the user files a overtime for a week, it would save it per day, well, kinda like this.

idno overtime from overtime to
19960072 2012-07-03 07:00:00 2012-07-06 08:00:00

well, the above statement is shortened, it should have the shift start and end of an employee, time in and time out of an employee and many many more.


this is the sql query used in the report.


select A.*,
L.leave_cde,
L.applied,
L.wpay,
L.reason,
L.dtfrom as [leave_dtfrom],
L.dtto as [leave_dtto],

convert(SMALLDATETIME,convert(varchar,O.otdtfrom,1 01) + ' ' + convert(varchar,O.otstart,108)) as [otdtfrom],
convert(SMALLDATETIME,convert(varchar,O.otdtto,101 ) + ' ' + convert(varchar,O.otend,108)) as [otdtto],
convert(SMALLDATETIME,convert(varchar,O.advdtfrom, 101) + ' ' + convert(varchar,O.advotstart,108)) as [advdtfrom],
convert(SMALLDATETIME,convert(varchar,O.advdtto,10 1) + ' ' + convert(varchar,O.advotend,108)) as [advdtto],
convert(SMALLDATETIME,convert(varchar,O.spldatefro m,101) + ' ' + convert(varchar,O.splotstart,108)) as [spldatefrom],
convert(SMALLDATETIME,convert(varchar,O.spldateto, 101) + ' ' + convert(varchar,O.splotend,108)) as [spldateto],

convert(smalldatetime,D.dyn_value) as [holidaydate],
D.dyn_key as [holidaytype],
D.dyn_name as [holidayname],
E.resigned,
case when AL.al_month is not null then 1 else 0 end as [al]
into #tempA
from attendance_table A
left join leavebalances L on
L.emp_cde=A.emp_cde
and A.ref_no=L.leaveref_no
and cast(convert(varchar,A.shift_from,101) as smalldatetime) between L.dtfrom and L.dtto
left join overtime O on
O.emp_cde=A.emp_cde
and A.otrefno=O.refno
and ( (cast(convert(varchar,A.shift_from,101) as smalldatetime) between O.otdtfrom and O.otdtto)
or (cast(convert(varchar,A.shift_from,101) as smalldatetime) between O.advdtfrom and O.advdtto)
or (cast(convert(varchar,A.shift_from,101) as smalldatetime) between O.spldatefrom and O.spldateto)
)
left join dyntable D on
D.dyn_key like '%holiday%'
and cast(convert(varchar,A.shift_from,101) as smalldatetime)=convert(smalldatetime,D.dyn_value)
left join employee E on
E.emp_cde=A.emp_cde
left join al_maintenance_table AL on
cast(convert(varchar,A.shift_from,101) as smalldatetime) =
CONVERT(smalldatetime, convert(varchar,AL.al_month) + '/' + convert(varchar,AL.al_day) + '/' + convert(varchar,AL.al_year)
)
where --A.div_cde='XO0' and
--A.dept_cde='A10' and
E.div_cde not in ('XO5','OJ0','CL0') and
E.rankdesc not in ('M','') and
E.hired <= @datefrom and
cast(convert(varchar,A.shift_from,101) as smalldatetime) between @datefrom and @dateto
order by A.shift_from

to test it, i used this variables

declare @datefrom as smalldatetime
declare @dateto as smalldatetime

set @datefrom='7/1/2012'
set @dateto='7/31/2012'


what i would like to do is something like this:


idno overtime from overtime to
19960072 2012-07-03 07:00:00 2012-07-03 08:00:00
19960072 2012-07-04 07:00:00 2012-07-04 08:00:00
19960072 2012-07-05 07:00:00 2012-07-05 08:00:00
19960072 2012-07-06 07:00:00 2012-07-06 08:00:00

to make it simple, i would like to have a query which, from a date range eg: 2012-07-03 07:00:00 2012-07-06 08:00:00
to something like the above statement. thanks for any help which you could provide me

Reply With Quote
  #2  
Old October 29th, 2012, 12:25 AM
narrokk narrokk is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 31 narrokk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 42 sec
Reputation Power: 1
Do you think guys this is too difficult? i think so too hahaha so i want to know any answers... please... or do you guys need some other information?

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > Week range to single day

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap