Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi All,

How to display the date-names between two days in sql-server using Stored procedure,c#.

my input like this from-date is 1/2/2013 (dd/mm/yy)
to-date is 7/2/2013 (dd/mm/yy)


output must be like this

date-names

Friday,
Saturday,
Sunday
Monday
Tuesday
Wednesday
Thursday


please help me

thanks and regards
Posted
Comments
Sergey Alexandrovich Kryukov 15-Feb-13 1:10am    
What did you try so far?
—SA
Ankur\m/ 15-Feb-13 1:13am    
What have you tried? Google on how to display day in sql, try writing some query. You will never learn if you just come here and ask people to write query for you.

1 solution

Try this out.
SQL
WITH sample AS 
(
  SELECT CAST('2013-02-01' AS DATETIME) AS dt
  
  UNION ALL
  
  SELECT DATEADD(dd, 1, dt)
  FROM sample s
  WHERE DATEADD(dd, 1, dt) <= CAST('2013-02-07' AS DATETIME)
)
   
SELECT datename(dw, dt) AS DataName
FROM sample


Thanks...
 
Share this answer
 
Comments
Santhosh23 15-Feb-13 2:03am    
Hi Tadit dash,
Thank so much.. your code is working fine..
Hi @Santhosh23,

My pleasure. Anytime.

Please accept this answer, if it has helped you in any way.
This will help others to find the answer in one go and you will also be awarded with some points for this action...

Thanks,
Tadit

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