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 2005 Forums
 Transact-SQL (2005)
 need to create a date

Author  Topic 

csphard
Posting Yak Master

113 Posts

Posted - 2008-05-23 : 18:08:20
I need to create the following date using sql.

I want the month and day to be 07/01 but for the
year I need the current year.

I thought I could do something like '07/01/' + YEAR(getdate())
but this error.


Thanks

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2008-05-23 : 18:10:38
easiest, cleanest way in my opinion is with a simple Date() UDF:

http://weblogs.sqlteam.com/jeffs/archive/2007/01/02/56079.aspx

Then, you just write:

set @yourdate = dbo.Date(year(getdate()), 7, 1)

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page
   

- Advertisement -