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 |
archana23
Yak Posting Veteran
89 Posts |
Posted - 2014-10-28 : 11:26:01
|
Hi, I am using below query to get the today date and time(2 hrs more than actual time)select dateadd(HOUR, 2, getdate()) as time_added the result of above query is "2014-10-28 13:19:09.343" but I want time up hours like shown below"2014-10-28 13:00"ThanksArchana |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2014-10-28 : 11:40:22
|
[code]select dateadd(hour, datediff(hour, 0, getdate()) + 2, 0)[/code] KH[spoiler]Time is always against us[/spoiler] |
|
|
archana23
Yak Posting Veteran
89 Posts |
Posted - 2014-10-29 : 10:23:14
|
thank you..it workedArchana |
|
|
archana23
Yak Posting Veteran
89 Posts |
Posted - 2014-10-29 : 19:06:02
|
Can I get the date as yyyymmdd format I mean my result should be like below"20141028 13:00"Thank you..Archana |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2014-10-30 : 04:19:57
|
that is formatting issue. You should do this in your front end application KH[spoiler]Time is always against us[/spoiler] |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
archana23
Yak Posting Veteran
89 Posts |
Posted - 2014-10-30 : 10:14:37
|
If I added like thisselect dateadd(dd, datediff(dd, 0, CONVERT(VARCHAR(10), getdate(), 112)), 0)I am not getting correct resultsgetting as "2014-10-30 00:00:00.000"can you please help me on this?Archana |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2014-10-30 : 23:58:13
|
[code]select replace(convert(varchar(16), dateadd(hour, datediff(hour, 0, getdate()) + 2, 0), 121), '-', '')[/code] KH[spoiler]Time is always against us[/spoiler] |
|
|
|
|
|
|
|