Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 changing the year in a date to the current year

Author  Topic 

bhdijkstra
Starting Member

24 Posts

Posted - 2011-11-06 : 04:53:01
Hi all,

I need some help with the following:

- i need to know on which day the date of birth this year will fall
- i know you can get the dayname by using the datepart(dw, date) as picking up the dayname in the query
- what i really want is a kind of CONVERT(VarChar, date, xxx) query to get the following:

dayname, date converted full (dd monthname yyyy)

Thanks for your help.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-11-06 : 04:57:32
[code]
declare @date date

select @date = '1987-06-05'

select dateadd(year, year(getdate()) - year(@date), @date)
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

bhdijkstra
Starting Member

24 Posts

Posted - 2011-11-07 : 05:37:53
this is not the solution. anyone else?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-11-07 : 06:29:51
quote:
Originally posted by bhdijkstra

this is not the solution. anyone else?


why?
at least explain what you were expecting instead with some sample data and output.Unless you explain your rules we cant understand what logic you're looking at

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -