Click here to Skip to main content
12,248,777 members (43,927 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# SQL-Server
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 14-Feb-13 20:07pm
Comments
   
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

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Try this out.
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...
Comments
Santhosh23 15-Feb-13 2:03am
   
Hi Tadit dash,
Thank so much.. your code is working fine..
Tadit Dash 15-Feb-13 2:06am
   
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160426.1 | Last Updated 15 Feb 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100