Blue Theme Orange Theme Green Theme Red Theme
 
6 Months Free & No Setup Fees ASP.NET Hosting!
Home | Forums | ASP.NET 2.0 Tutorials | Web Services | How Do I...? | Class Browser | WPF Quick Starts | Advertise with Us
 | Consulting  
Submit an Article Submit a Blog 
Search :       Advanced Search »
Home » Blogs Home » Blog Detail

How to get Week First and Last day and also running week Number using Sql server

 by Dhaval Patel on Jan 17, 2012

Sql server using make Last day and First day of week and current week.
Comments: 0 Views: 470 Printable Version 
    Using sql server Get Today Week no of day and Fist and Last day of week

 Select GETDATE() AS 'Today', DATEPART(Week,GETDATE()) AS 'Week No of Today', 
DATEADD(DAY , -DATEPART(WEEKDAY,(DATEADD( DAY , 7-DATEPART(WEEKDAY,GETDATE()),GETDATE())))
+ (7-DATEPART(WEEKDAY,GETDATE()))+1 ,GETDATE()) 'First Day Of This Week',
DATEADD(DAY , 7-DATEPART(WEEKDAY,GETDATE()),GETDATE()) AS 'Last Day Of Week'



Getdate()  returns today's date

datepart(week,getdate()) returns current week no



Comment Request!
Thank you for reading this post. Please post your feedback, question, or comments about this post Here.
 
What do you say about this post? Post a comment here
*Title:
*Comment:
 
Comments not available.
Team Foundation Server Hosting
Become a Sponsor

 Blogger's Profile
Age: Not Available
Location:
Title: Developer
Joined: Mar 26, 2010
Education: Bachelors Degree
 More Blogs from this Blogger
No record available
 Latest Blogs
[Video] OnClose Handler
[Video] Storing and Loading the Window and Toolbar position
The Euclidean Algorithm
Swapping Exe Process
How Exe file is Generated by VS2005 C++ Project?
What is Exe
Header files: Multiple Inclusion problem - Solution B
Header files: Multiple Inclusion problem - Solution A
Header files: Multiple Inclusion problem - Reason
Header files: Multiple Inclusion problem
View all »
 Latest Jobs
More ... 
 Latest Interview Questions
More ... 
6 Months Free & No Setup Fees ASP.NET Hosting!
 © 2012  contents copyright of their authors. Rest everything copyright Mindcracker. All rights reserved.