Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
SQL
DECLARE @PDate datetime
  UPDATE MASTERPROCESSDAILYDATA SET Status =  CASE WHEN  CAST(@PDate AS TIME ) BETWEEN CAST ('08:00' AS TIME)
             AND CAST('09:30'  AS TIME) THEN 'P'
             WHEN  CAST(@PDate AS TIME ) BETWEEN CAST ('16:00' AS TIME)
             AND CAST('17:30'  AS TIME) THEN 'P'
              WHEN  CAST(@PDate AS TIME ) BETWEEN CAST ('09:31' AS TIME)
             AND CAST('15:59'  AS TIME) THEN 'HL'
             ELSE 'A'

            END
            SELECT *FROM MASTERPROCESSDAILYDATA where PDate ='02-1-13'




when i am trying to execute this query, Status is updated only ELSE Condition(DEFAULT)
Can anyone help me to solve this problem


@PDate datetime
@In_Punch datetime
@Out_Punch datetime
Posted
Comments
Karthik Achari 30-Dec-13 4:37am    
Can you tell me where to set @PDate because I am a begineer to SQL
Eg: @PDate between '02-1-13' AND '02-28-13'

1 solution

You are not setting a value for PDate in this code. Therefore, it is null. Which is your else case.
 
Share this answer
 
Comments
Karthik Achari 30-Dec-13 4:28am    
Thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900