Solved

timestamp

Posted on 2006-06-19
2
973 Views
Last Modified: 2008-03-10
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
0
Comment
Question by:dalebrumbaugh
2 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 16935855
Declare @TimeString nvarchar(50)
select @TimeString = convert(varchar(30),current_timestamp,120)
0
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 500 total points
ID: 16935866
Declare @TimeString nvarchar(50)
set @TimeString = CONVERT(varchar,getdate(),121)
SELECT @TimeString
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
MS SQL Bulk load data error 5 34
Help with SQL Query 23 39
SQL Script to find duplicates 16 20
combine an MS SQL string in Idera DM 9 31
In this article—a derivative of my DaytaBase.org blog post (http://daytabase.org/2011/06/18/what-week-is-it/)—I will explore a few different perspectives on which week today's date falls within using Microsoft SQL Server. First, to frame this stu…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now