Question:
SQL query to display all dates which are "Friday" in a year?
SubbaRao P
2011-12-17 03:33:23 UTC
SQL query to display all dates which are "Friday" in a year?
Three answers:
arch_lance
2011-12-17 04:24:26 UTC
for timestamp type ( 2011-12-13 11:46:32 )



SELECT the_field FROM the_table WHERE DATE_FORMAT( the_date_field, '%a' ) = 'Fri'





for number type ( 1324113648 )



SELECT the_field FROM the_table WHERE DATE_FORMAT( FROM_UNIXTIME( the_date_field ), '%a' ) = 'Fri'
sudhi
2011-12-17 12:08:30 UTC
Assuming you are using MS-Sql server 2005. The below coding lines may help you.



declare @dt datetime

set @dt = '2011-01-01'

while @dt <= '2011-12-31'

begin

if datename(dw,@dt) = 'Friday'

print @dt

set @dt = @dt + 1

end
Nagesh
2011-12-17 11:48:28 UTC
Let us know more details about DB.. is that a simply date fields input given by user or system timestamps you are talking about. let us know the format of date


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...