February 4, 2010 at 10:43 pm
Hi There,
I am trying to use DATEADD function as follows:
SELECT DATEADD(MINUTE,(CONVERT(DATETIME,CONVERT(VARCHAR,20100501),121)),'02/05/2010')
I am getting error as:
"Argument data type datetime is invalid for argument 2 of dateadd function."
Suggest me some way.
Thank you.
February 5, 2010 at 1:09 am
Not sure what you are trying to achieve here. I also suggest you check BOL to understand the syntax, but here's two additional comments:
1. why write convert(varchar,20100201) and not '20100201'?
2. you specify format 121 to do the conversion from a string to a datetime but this format is not consistent with the format of your string - again, check BOL. But you also may find this article useful.
February 7, 2010 at 11:47 pm
You have made a mistake in the parameters of DateAdd function.
Second parameter is the number of minutes you need to add to the date given as the third parameter. So, try this:
SELECT DATEADD(MINUTE,10,'02/05/2010')
--Divya
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply