timestamp

I want to preserve the seconds and milliseconds in the timestamp when I assign it to a variable:

select current_timestamp

returns:
2006-06-19 12:00:34.770


Declare @TimeString nvarchar(50)
set @TimeString = (select current_timestamp)

returns:
Jun 19 2006 11:58AM
dalebrumbaughAsked:
Who is Participating?
 
Aneesh RetnakaranConnect With a Mentor Database AdministratorCommented:
Declare @TimeString nvarchar(50)
set @TimeString = CONVERT(varchar,getdate(),121)
SELECT @TimeString
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
Declare @TimeString nvarchar(50)
select @TimeString = convert(varchar(30),current_timestamp,120)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.