Click here to Skip to main content
Rate this: bad
good
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
Sergey Alexandrovich Kryukov at 15-Feb-13 1:10am
   
What did you try so far?
—SA
Ankur\m/ at 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 at 15-Feb-13 2:03am
   
Hi Tadit dash,
Thank so much.. your code is working fine..
Tadit Dash at 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
0 Zoltán Zörgő 300
1 Peter Leow 160
2 BillWoodruff 120
3 CHill60 100
4 bling 80
0 Sergey Alexandrovich Kryukov 9,423
1 OriginalGriff 6,891
2 Peter Leow 4,692
3 Zoltán Zörgő 4,344
4 CHill60 2,932


Advertise | Privacy | Mobile
Web01 | 2.8.150129.1 | Last Updated 15 Feb 2013
Copyright © CodeProject, 1999-2015
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