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 |
|
GaneshRamanan
Starting Member
40 Posts |
Posted - 2011-03-29 : 09:24:41
|
| SELECT DATEADD(HH,CONVERT(VARCHAR(5),CONVERT(DATETIME,GETDATE(),108),108),GETDATE())I WANTS TO ADD THE HOURS WITH THE Date, WHEN I RUN THIS QUERY I AM GETTING THIS ERROR. PLS ANYONE PROVIDE ME A SOLUTION.Argument data type varchar is invalid for argument 2 of dateadd function.How I should add the hours?Thanks,Ganesh Ramanan+919865115549. |
|
|
Seventhnight
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2011-03-29 : 09:39:44
|
[code]Select GETDATE(), --Now DATEPART(hh,getdate()), --Hour of now dateadd(hh,DATEPART(hh,getdate()),getdate()), -- what i sounds like you asked for DATEADD(hh,datediff(hh,0,getdate()),0), -- other possibility 1 DATEADD(hh,datediff(hh,0,getdate())+DATEPART(hh,getdate()),0) -- other possibility 2[/code]... did one of those work?Corey snSQL on previous signature "...Oh and by the way Seventhnight, your signature is so wrong! On so many levels, morally, gramatically and there is a typo!" |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-03-29 : 09:48:19
|
"I WANTS TO ADD THE HOURS WITH THE Date"what do you want exactly ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
GaneshRamanan
Starting Member
40 Posts |
Posted - 2011-03-29 : 09:50:54
|
| Its working..Thanks so much |
 |
|
|
Seventhnight
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2011-03-29 : 10:16:40
|
which is working... which one were you looking for?Corey snSQL on previous signature "...Oh and by the way Seventhnight, your signature is so wrong! On so many levels, morally, gramatically and there is a typo!" |
 |
|
|
|
|
|
|
|