Solved

Day of the year function in tsql

Posted on 2007-11-26
2
3,567 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 125 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
I have a large data set and a SSIS package. How can I load this file in multi threading?
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.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

691 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