Click here to Skip to main content
15,886,689 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I am using Below Code in sqlquery

SQL
select * from Accounts_LeaveEntry where Staff_Id=1012  and To_Date <> datename(dw,To_Date)='Sunday'


But this code not worked,so how to find Particlar Day(Sunday) not Visible

Example Table:
SQL
Staff_Id	To_Date	      Total_Days	Leave_Type	Inform_Type
1012	2014-09-07        	2	        Fullday	        Not Informed
1012	2014-09-12      	1	        Fullday	        Prior
1012	2014-09-14      	2	        Fullday	        Not Informed
1012	2014-09-21      	2	        Fullday	        Not Informed
1012	2014-09-28      	2	        Fullday	        Not Informed


The above table data I don't want Sunday , so i want Result is
SQL
Staff_Id	To_Date	     Total_Days	Leave_Type	Inform_Type
1012	        2014-09-12 	1	Fullday	         Prior
Posted
Updated 5-Dec-14 3:24am
v2
Comments
Herman<T>.Instance 5-Dec-14 9:26am    
Still not working?

check this

SQL
select * from Accounts_LeaveEntry where Staff_Id=1012 and datename(dw,To_Date)<> 'Sunday'
 
Share this answer
 
hi,

try this

select * from Accounts_LeaveEntry where Staff_Id=1012 and datename(WEEKDAY ,CONVERT(DATETIME,To_Date,103)) <> 'Sunday'
 
Share this answer
 
v3
Hi,
Please try this solution:

SQL
SELECT *, DATENAME(weekday,To_Date) as [DayName]
FROM Accounts_LeaveEntry 
where Staff_Id=1012  DATENAME(weekday, To_Date)<>'Sunday'


I have added DayName column to show you the returned day name.
 
Share this answer
 
v2
Try This!..

SQL
select * from #temp6dec where StaffId=1012  and datename(dw,To_Date)!='Sunday'
 
Share this answer
 
hi Nirmal Chandru,

Try This

select * from Accounts_LeaveEntry where Staff_Id=1012 and datename(WEEKDAY ,CONVERT(DATETIME,To_Date,103)) <> 'Sunday'
 
Share this answer
 

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