Link to home
Start Free TrialLog in
Avatar of scm0sml
scm0sml

asked on

Changing the time value of a sql datetime

Hi How can I set just the time value of a datetime:

for example

DECLARE @ENDDATE SMALLDATETIME
SET @ENDDATE = GETDATE()

If i wanted to then amend the time value of @ENDDATE, how would I do this?
Avatar of Aneesh
Aneesh
Flag of Canada image

select CONVERT(varchar,getdate(), 108)
make sure that you store that value in a Varchar column
declare @Time = varchar(10)
select @Time = CONVERT(varchar,getdate(), 108)
Avatar of scm0sml
scm0sml

ASKER

say i have

SET @TESTDATE = GETDATE()

That will give me the date and time for now.

But say I wanted to set the time value of @TESTTIME to 09:30 for example.

How can i do this?
SOLUTION
Avatar of imitchie
imitchie
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial