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.
Author |
Topic |
MCusuma1
Starting Member
13 Posts |
Posted - 2013-09-19 : 10:15:19
|
Hello, I have been trying to figure this out. I need to get May 1st of the previous year. I have the following but it is not working:SELECT DATEFROMPARTS(DATEADD(yy, -1, GETDATE()), 5, 01)I get the error message "Msg 257, Level 16, State 3, Line 1Implicit conversion from data type datetime to int is not allowed. Use the CONVERT function to run this query."I'd appreciate any help. |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-09-19 : 10:32:00
|
Use DATEFROMPARTS(year(getdate())-1,5,1) |
|
|
MCusuma1
Starting Member
13 Posts |
Posted - 2013-09-19 : 10:50:57
|
quote: Originally posted by James K Use DATEFROMPARTS(year(getdate())-1,5,1)
This worked great thanks! |
|
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-09-19 : 11:03:28
|
You are very welcome - glad to help. |
|
|
sigmas
Posting Yak Master
172 Posts |
Posted - 2013-09-19 : 11:17:38
|
quote: Originally posted by MCusuma1 Hello, I have been trying to figure this out. I need to get May 1st of the previous year. I have the following but it is not working:SELECT DATEFROMPARTS(datepart(yy,DATEADD(yy, -1, GETDATE())), 5, 01)
|
|
|
|
|
|
|
|