Loop in Sqlserver

Hi,

If the User passes date as 25/Feb/2015 06 AM and Shifts a 4 and Qty as 2000 (2000/4 = 500) then in my table i need to store the values as

StartDate                             EndDate                           Numbers

25/Feb/2015 06:00             25/Feb/2015 14:00             500

25/Feb/2015 14:00             25/Feb/2015 22:00             500

25/Feb/2015 22:00             26/Feb/2015 06:00             500

26/Feb/2015 06:00             26/Feb/2015 14:00             500

If the User passes date as 25/Feb/2015 11 AM and Shifts a 5 and Qty as 2000  then in my table i need to store the values as

StartDate                             EndDate                           Numbers

25/Feb/2015 11:00             25/Feb/2015 14:00             300

25/Feb/2015 14:00             25/Feb/2015 22:00             500

25/Feb/2015 22:00             26/Feb/2015 06:00             500

26/Feb/2015 06:00             26/Feb/2015 14:00             500

26/Feb/2015 14:00             26/Feb/2015 17:00             200

Any Suggestiongs

February 25th, 2015 4:51am

And your question is?

btw, you don't have said how your shift times are determined nor how the numbers splitting should work in general.

Free Windows Admin Tool Kit Click here and download it now
February 25th, 2015 8:06am

Hi,

I have 3 shifts

Shift A 6 am to 2 Pm

Shift B 2 pm to 10 PM

Shift c 10 PM to 6 AM

Suppose if i produce 1 Number for a Minute then based on time difference startdate and enddate i need to calculate the numbers and show.

February 25th, 2015 9:07am

In the second case, How is the number 300 and 200 calculated, as well how is the endDate 26/Feb/2015 17:00 determined for the rows that out of shift?
Free Windows Admin Tool Kit Click here and download it now
February 26th, 2015 2:10am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics