Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Two different reports calculating time differrences - same code - different results

$
0
0

I have 2 reports that share common code - they calculate a time difference in minutes - and count the number of items passing thorough a given process during the manufacturing process (Sorry I cannot be more specific - NDA involved).

Here is an example of the code running in both stored procedures.  The results are written to a temp table.

COUNT(CASE    WHEN    
             CONVERT(VARCHAR(12),ProcessDate,114)    BETWEEN    CONVERT(VARCHAR(12),'19:30:00.000',114)
                                                                                           AND    CONVERT(VARCHAR(12),'19:59:59.999',114)
                    THEN    MachineID
            END)    AS    'TimeSlice1930_2000'

I am counting the items in 30 minute time slices and I am getting 1 minute differences in the results between the 2 reports.

Same data, same code - the only difference is in the WHERE clause

procedure 1

 WHERE    MachineID    NOT    IN    (
                            'RRO 1',
                            'TUO 1',
                            'TUO 2'
                            )
   AND    ProcessDate    BETWEEN    @StartDate
                                              AND    @EndDate

Procedure 2

 WHERE    MachineID    LIKE    'Ins%'
   AND    InspectionDate    BETWEEN    @StartDate
                                                  AND    @EndDate

Any idea why?  Is this a rounding thing?  If I write the data into a real table object instead of a temp table the data type selected when I do a SELECT INTO is INT.

Help!!!


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>