954,560 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Get SQL Date without the year

Hello everyone!

I'm trying to get a date from SQL without the year. Every code I've seen has included the year. Here is what I have now.

SELECT * , convert(CHAR, \"date\", 10) AS ndate from dbo.MYDB where 35 > DATEDIFF(d,\"date\", GETDATE())";


I would like ndate to be show like mm-dd with now year.

Any suggestions?

Thank you!

agr8lemon
Light Poster
30 posts since Aug 2009
Reputation Points: 10
Solved Threads: 0
 

Use a combination of convert and substring to pick off the first 5 characters, then concatenate with year.

substring(convert(char(8), getdate(), 10), 1, 5)
BitBlt
Master Poster
711 posts since Feb 2011
Reputation Points: 367
Solved Threads: 109
 

Use a combination of convert and substring to pick off the first 5 characters, then concatenate with year.

substring(convert(char(8), getdate(), 10), 1, 5)

Excellent, thank you!

agr8lemon
Light Poster
30 posts since Aug 2009
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: