469,578 Members | 1,742 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,578 developers. It's quick & easy.

Dynamically Modify the Datepart Argument of DATEADD function in T-SQL

Is it possible to dynamically modify the Datepart argument of the DATEADD function in T-SQL 2005.

I am trying to do something like this but it's not happy with parameter 1:


DECLARE @pp NCHAR(3)
SET @pp = 'day'
SELECT dateadd(@pp,3,'2007-07-14 12:00:00')

Any Ideas will be much appreciated.
Jul 29 '07 #1
1 3626
ck9663
2,878 Expert 2GB
Is it possible to dynamically modify the Datepart argument of the DATEADD function in T-SQL 2005.

I am trying to do something like this but it's not happy with parameter 1:


DECLARE @pp NCHAR(3)
SET @pp = 'day'
SELECT dateadd(@pp,3,'2007-07-14 12:00:00')

Any Ideas will be much appreciated.

put the entire select command to a variable
Jul 30 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by wjbell | last post: by
4 posts views Thread by ey.markov | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.