?
Solved

Day of the year function in tsql

Posted on 2007-11-26
2
Medium Priority
?
3,576 Views
Last Modified: 2008-02-01
is there a way to determine the day of the year given a date in sql server.  For example, 1/1/2007 would return 1, 2/1/2007 would return 32....

Thanks,
ptran
0
Comment
Question by:ptran2000
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 29

Expert Comment

by:QPR
ID: 20354704
you could use datediff to calculate the number of days between 1/1/2007 and the supplied date.
If not 2007 then take the year part of the supplied date and convert that to 1/1/yyyy
then use this to calculate
0
 
LVL 7

Accepted Solution

by:
macentrap earned 500 total points
ID: 20354764
SELECT DATEPART(y, GETDATE()) AS 'Day of the Year'

SELECT DATEPART(y, '2007-12-02') AS 'Day of the Year'
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have a large data set and a SSIS package. How can I load this file in multi threading?
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question