Camillia
asked on
Concating time with date
Not sure how this happened. Today, at 10:17AM, clicked on a button on a page.
Code passes "date" ONLY to the stored proc. I'm using a telerik control and it wont let me add "time". So, i pass the date, and in the stored proc, i contact date to time...
In this example, "10:17AM" came out as "10:17PM". Not sure why and how but this is my sql below.
Code passes "date" ONLY to the stored proc. I'm using a telerik control and it wont let me add "time". So, i pass the date, and in the stored proc, i contact date to time...
In this example, "10:17AM" came out as "10:17PM". Not sure why and how but this is my sql below.
declare @updatedate as datetime
set @updatedate ='2011-03-25'
-- getdate() (time at that time) was 2011-03-25 10:17:15.000
select
DATEADD(day, 0, DATEDIFF(day, 0, @updatedate)) +
DATEADD(day, 0 - DATEDIFF(day, 0, getdate()), getdate())
--not sure how that turned out to be 21:10:15:000
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
if you want to add "Date & Time" of current time, then why not uses getdate() right away?
since if you pass in any date which is not "today", then why try to add time of getdate() ?
unless you will have another parameter @updatetime = '10:17am'
then you may use script as below
Open in new window