Weird Millisecond Part Of Datetime Data In SQL Server 2000
Dec 18, 2006
Execute following T-SQL within Queary Analyzer of SQL Server 2000:
=======================================
DECLARE @dTest DATETIME
SET @dTest='2001-1-1 1:1:1:991'
SELECT @dTest
SET @dTest='2001-1-1 1:1:1:997'
SELECT @dTest
SET @dTest='2001-1-1 1:1:1:999'
SELECT @dTest
=======================================
You get what?
This is my result which is weird:
2001-01-01 01:01:01.990
2001-01-01 01:01:01.997
2001-01-01 01:01:02.000
Then what's the reason of this weird problem?
View 3 Replies
ADVERTISEMENT
Jul 9, 2007
Hi,
I'm inserting a datetime values into sql server 2000 from c#
SQL server table details
Table nameate_test
columnname datatype
No int
date_t DateTime
C# coding
SqlConnection connectionToDatabase = new SqlConnection("Data Source=.\SQLEXPRESS;Initial Catalog=testdb;Integrated Security=SSPI");
connectionToDatabase.Open();
DataTable dt1 = new DataTable();
dt1.Columns.Add("no",typeof(System.Int16));
dt1.Columns.Add("date_t", typeof(System.DateTime));
DataRow dr = dt1.NewRow();
dr["no"] = 1;
dr["date_t"] = DateTime.Now;
dt1.Rows.Add(dr);
for(int i=0;i<dt1.Rows.Count;i++)
{
string str=dt1.Rows["no"].ToString();
DateTime dt=(DateTime)dt1.Rows["date_t"];
string insertQuery = "insert into date_test values(" + str + ",'" + dt + "')";
SqlCommand cmd = new SqlCommand(insertQuery, connectionToDatabase);
cmd.ExecuteNonQuery();
MessageBox.Show("saved");
}
When I run the above code, data is inserted into the table
The value in the date_t column is 2007-07-09 22:10:11 000.The milliseconds value is always 000 only.I need the millisecond values also in date_t column.
Is there any conversion needed for millisecond values?
thanks,
Mani
View 3 Replies
View Related
Mar 19, 2008
Because SSIS truncates the milliseconds from an SQL datetime datatype I figured I'd convert my datetime values to strings:
SELECT CONVERT(VarChar(30),ICINVMax,109) AS ICINVMax
I map ICINVMax to a string variable in the result set.
The string variable seems to work fine with an Execute SQL Task such as:
Select count (DISTINCT ICINVENTORY.ICINVNumber) AS NumRows
FROM ICINVENTORY
WHERE ICINVENTORY.ICINVLastChgAt > ? (? is mapped to the package variable)
However when I try the same SQL string in an OLE DB Source I get an error - "Invalid character value for cast specification".
Any ideas????
View 11 Replies
View Related
Mar 20, 2007
Hello. I've seached the this forum and others for this question of mine but couldn't get any thing. Everyone know that in MSSQL, the precision of datetime is currently limited to 1/300th of a second. My question is, is there any way to store the actual millisecond in the a table? Also, later, able to pull it up from the table? What are the options?
Please advise.
Thanks,
Rick..
View 11 Replies
View Related
Jan 18, 2007
I'm running into a constant issue of SQL Server modifying themillisecond part of a timestamp insert from another application. Theapplication inserts timestamp which includes a millisecond portion as astring (varchar). But when an SQL Server moves this data to anothertable (for reporting), the string is inserted in a datetime field, themillisecond field invariably changes by 1-2 milliseconds for everysingle data point inserted. Given the time critical nature of this data(to a millisecond), its almost impossible to avoid this other than toleave the data as string type. But this drives the analytical reportingfolks wild as report queries based on time criteria are getting messedup. Any ideas how to force SQL Server not to mess around with themillisecond value? Does this problem exist with SQL Server 2005 as well?
View 2 Replies
View Related
Aug 2, 2006
I was able to successfully create a database maintenance plan for SQL Server 2000 Transaction Log Shipping for a few databases a few weeks ago. Yesterday, I created a few more but to my surprise, I can no longer do it. I can create a maintenance plan but the job it creates does not start even if I force the job to start. I did exactly the same thing as what I did (as I document everything I do) before but no luck.
Has anybody had this experience before?
View 5 Replies
View Related
Dec 20, 2004
I have a datetime field with a value of '-28049-03-16 10:01:16.267' in SQl Server 2000. I haven't a clue how or why this value was entered as I did not design or write the database. However, I do have the task of writing a DTS package to export the data to Access. The problem is that the DTS fails when it tries to export the record with the above value into an Access table with a Date/Time field. I thought I could get round this by using a UDF to say if the date equals this value then make it null:
RETURNS DateTime
As
BEGIN
DECLARE @CheckDate varChar(300)
SET @CheckDate = CONVERT(varChar(300),@Date)
IF (@CheckDate = '-28049-03-16 10:01:16.267')
BEGIN
SET @Date = Null
END
RETURN (@Date)
END
However when I use the UDF it gives me the following error:
Server: Msg 542, Level 16, State 1, Procedure UDFn_CheckDate, Line 23
An invalid datetime value was encountered. Value exceeds the year 9999.
I have tried many variations of Convert, Cast etc. but still can't get it to work.
Anybody got any ideas???
View 8 Replies
View Related
Jan 15, 2008
So what I'm trying to do is audit changes on a server. I'm creating a DDL trigger as below:
Code Block
CREATE trigger DDL_changeTracking_tr
on Database
FOR CREATE_TABLE, ALTER_TABLE, DROP_TABLE,
CREATE_FUNCTION, ALTER_FUNCTION, DROP_FUNCTION,
CREATE_PROCEDURE, ALTER_PROCEDURE, DROP_PROCEDURE,
CREATE_TRIGGER, ALTER_TRIGGER, DROP_TRIGGER,
CREATE_VIEW, ALTER_VIEW, DROP_VIEW
as
SET NOCOUNT ON
SET ANSI_WARNINGS ON
SET ANSI_NULLS ON
SET ANSI_PADDING ON
SET ARITHABORT ON
SET CONCAT_NULL_YIELDS_NULL ON
SET NUMERIC_ROUNDABORT OFF
SET QUOTED_IDENTIFIER ON
BEGIN TRY
BEGIN
declare @login varchar(100)
set @login = eventData().value('(/EVENT_INSTANCE/LoginName)[1]', 'varchar(100)')
if (@login <> 'sqladmin' and @login <> 'sqlagentadmin')
BEGIN
insert into DBMonitoring..audit_tbl (databaseId, auditTime, loginName, objectName, objectType, eventType)
select
DB_ID() as databaseId
, getDate() as auditTime
, eventData().value('(/EVENT_INSTANCE/SchemaName)[1]', 'varchar(100)') + '.' +
eventData().value('(/EVENT_INSTANCE/ObjectName)[1]', 'varchar(100)') as objectName
, eventData().value('(/EVENT_INSTANCE/ObjectType)[1]', 'varchar(100)') as objectType
, eventData().value('(/EVENT_INSTANCE/LoginName)[1]', 'varchar(100)') as LoginName
, eventData().value('(/EVENT_INSTANCE/EventType)[1]', 'varchar(100)') as eventType
END
END
END TRY
BEGIN CATCH
BEGIN
declare @html varchar(max)
select @html = '<html>' + getDate() + '</br>' + eventData().value('(/EVENT_INSTANCE/ObjectName)[1]', 'varchar(100)')
+ '</br>' + ERROR_MESSAGE() + '</html>'
PRINT 'Warning: Unable to submit change to audit'
SELECT ERROR_MESSAGE()
exec util_EmailOut_DatabaseMail_prc @from = '<address>',
@to = '<address>',
@cc = null,
@bcc = null,
@subject = 'Change Tracking Insert Failure',
@body = null,
@HTMLBody = @html,
@importance = 1,
@file = null
END
END CATCH
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
ENABLE TRIGGER DDL_changeTracking_tr ON DATABASE
It inserts the trigger data into:
Code Block
CREATE TABLE audit_tbl (
databaseId int not null,
--auditTime datetime default getDate() not null,
auditTime datetime not null,
loginName varchar(255) not null,
objectName varchar(255) not null,
objectType varchar(25) not null,
eventType varchar(40) not null
)
go
ALTER TABLE audit_tbl ADD CONSTRAINT PK_audit_tbl_databaseId_auditTime_objectName PRIMARY KEY (databaseId, objectName, auditTime)
CREATE NONCLUSTERED INDEX IX_audit_tbl_auditTime_loginName ON audit_tbl(auditTime, loginName)
CREATE NONCLUSTERED INDEX IX_audit_tbl_auditTime_objectType ON audit_tbl(auditTime, objectType)
In the same database that I've run this one, I'm running this code to test it:
Code Block
create procedure cow_prc
as select 1
go
drop procedure cow_prc
Occassionally when I run this, I get the following error:
Msg 241, Level 16, State 1, Procedure DDL_changeTracking_tr, Line 42
Conversion failed when converting datetime from character string.
I am completely lost on this. I've had 3 fellow DBAs look at it and they're not sure what's going on with it. I've even tried writing the trigger logic as a CTE which using isDate() to make sure that auditTime actually is a date.
Any insight would be greatly appreciated. Thanks in advance.
View 6 Replies
View Related
Aug 3, 2015
How can I calculate a DateTime column by merging values from a Date column and only the time part of a DateTime column?
View 5 Replies
View Related
Jul 7, 2006
Hi everyone,
I have developed a VB6 application that works with SQL server 2000. My client does not have a SQL server installed on their machine. I wonder do I have to purchase a copy of SQL server 2000 and install it to client's computer ?
How much would a basic version of SQL server 2000 cost ?
I am new to the softwarel world. Please give me some advise.
Thanks
View 8 Replies
View Related
Jul 23, 2005
Is there any other way which is more simpler(shorter) to get the datepart (I don't want the time part ) of Datetime than this ?Convert(nvarchar, DATEPART(dd,[Date]) ) + '/' + Convert(nvarchar,DATEPART(mm,[Date])) + '/' + Convert(nvarchar, DATEPART(yy,[Date])) As[Date]
View 1 Replies
View Related
Apr 29, 2008
I have a datetime user inputted parameter on a report. I want to display it on the report without the time part.
ie. it displays
4/8/2007 12:00:00 AM
I want just to display the date part
4/8/2007
Is this possible?
View 7 Replies
View Related
Apr 30, 2008
Dear all,
I have an application where I need to implement a Team Shift management.
The team shift table need to be defined as follow :
Shift table
=========
Id DateTime IsCurrent
1 08:00:00 True
2 16:00:00 False
3 00:00:00 False
From the table above the current running shift is Id = 1
Based on that I have following question:
1 - Is there a way to specified for a DateTime field that it will recieved only Time part ?
2 - When a shift change occurs, I need to compare the Current time with the time shift in the table. Then according to that I set the IsCurrent flag to proper new Shift ID.. how to perform this ?
Thnaks for your help
regards
serge
View 5 Replies
View Related
Feb 28, 2008
Hi All,
I would like to know, how the datetime will be stored in the sqlserver datetime column.
Because some time i am giving the date in dd/mm/yyyy and sometime mm/dd/yyyy.
while give the date in mm/dd/yyyy works fine but not in the another case. and also while i execute a query on query analyser it shows the datetime in
yyyy/mm/dd format.
So anyone can please tell me how the dates will be stored in the datetime column of sqlserver database?
Thanks in Advance.
Regards,
Dhanasekaran. G
View 2 Replies
View Related
Apr 27, 2015
I have a table with a datetime field (named "lnDateDone") and an integer field (named "PlannedHour"). I want to build a new datetime field with the same value as lnDateDone and replacing the hour part by the PlannedHour field. Example:
lnDateDone = '2014-04-09 13:22:31.544'
HourPlanned = 14
new datetime field = '2014-04-09 14:00:00'
I tried the following:
CAST(SUBSTRING(CAST(lnDateDone AS VARCHAR(25)),1,12) + CAST(PlannedHour AS VARCHAR(2)) + SUBSTRING(CAST(lnDateDone AS VARCHAR(25)), 15, LEN(lnDateHeureFin)) AS SMALLDATETIME) AS DatePrevue
but it won't work when casted in DateTime format, only in varchar, but I want it in datetime as I need to do compute some values using date manipulation functions.
How can I do that?
View 4 Replies
View Related
May 19, 2008
hai friends,
iam doing a project in .net and using sql server.
i need to compare only month and year part in datetime type to retrive data.
1)retrive unique year and its months available in the database.
like may 2008
apr 2008
mar 2007
View 3 Replies
View Related
Mar 11, 2006
from this, circdate being a datetime field:SQLQuery = "select distinct circdate from circdata order by circdate"I need the distinct date portion excluding the time part.this has come about when I discoveredI am inserting and updating some datetime values with the same value,but for some reason, the values are always off by a few seconds. I seta variable called SetNow assigned to NOW and then set the datetimefields to this SetNow variable. Then when I collect the distinct datetime I am assuming they will have the same values recorded incircdate, but no, they are off by several seconds. Makes no sense to meat all. I tried renaming the variable several times but it makes nodifference at all.any help appreciated, thanks.
View 5 Replies
View Related
Sep 18, 2015
I need to set only the date part of tblEventStaffRequired.StartTime to tblEvents.EventDate while maintaining the time part in tblEventStaffRequired.StartTime.
UPDATE tblEventStaffRequired
SET StartTime = <expression here>
FROM tblEvents INNER JOIN
tblEventStaffRequired ON tblEvents.ID = tblEventStaffRequired.EventID
View 4 Replies
View Related
Jun 11, 2007
why can't i connect from 2000 to 2005?
i get this msg.
to connect to this server you must use sql server management studio or sql server management objects
=============================
http://www.sqlserverstudy.com
View 8 Replies
View Related
Dec 14, 2005
After testing out the application i write on the local pc. I deploy it to the webserver to test it out. I get this error.
System.Data.SqlClient.SqlException: The conversion of a char data type to a
datetime data type resulted in an out-of-range datetime value.
Notes: all pages that have this error either has a repeater or datagrid which load data when page loading.
At first I thought the problem is with the date, but then I can see
that some other pages that has datagrid ( that has a date field) work
just fine.
anyone having this problem before?? hopefully you guys can help.
Thanks,
View 4 Replies
View Related
Aug 3, 2006
Publisher is 2005 x64, subscribers SS2000 (SP3) and SS2005 x64. Pull agents, no filters on subscriptions. We are seeing many seemingly random conflicts on between SS2000 subscriber and publisher. It happens on several different tables.
One table is never editted, only inserts happening everywhere and deletes happening on the SS2000 subscriber. Deletes will sometimes generate conflict. Reason is '"he row was deleted at 'CTS11.CTS' but could not be deleted at 'cts4a.cts'. Unable to synchronize the row because the row was updated by a different process outside of replication." CTS11 is SS2000 subscriber, CTS4A is publisher.
Probably unrelated bug but when looking at conflicts on this same table in SS2005 conflict viewer, get error "ID is neither a DataColumn nor a DataRelation for table summary (System.dATA)" and then "Column ID does not belong to table summary (System.Data)". ID column is rowguid, only unusual thing about table is that it has varchar(8000) field plus some other fields.
Other tables generate conflicts with this reason "The row was updated at 'CTS11.CTS' but could not be updated at 'cts4a.cts'. The merge process was unable to synchronize the row." I enabled verbose logging in the merge agent but the log file didn't contain any further explanation.
This same topology and schema worked fine when all publishers and subscribers were SS2000.
Any insight into how to fix this would be appreciated.
View 9 Replies
View Related
May 18, 2007
I have worked with many data mining softwares and found SQL Data mining part of Microsoft product needs to imrove a lot to whoo the customers.
View 10 Replies
View Related
Apr 8, 2015
My company is migrating all their servers to a new data center and I get to specify what we need for the db servers.
We've got a 22 prod servers (mainly physical) with a couple of TB of data on sql 2000 to 2012.
We expect to move to sql2014, and consolidate and virtualise where ever possible.
But I'd like start with specifying an overall architecture for this: some Best Practices to guide the build at a server and an installation level
View 1 Replies
View Related
Mar 19, 2007
Hi there
I have an application running in two development environments, one using a sql server 2005 database and the other using a 2000 database. The application works on the 2000 database but when i try to insert values into the 2005 database the date format is incorrect (mm/dd/yyyy). I've checked the regional data settings on both machines and they are identical. The application (which i inherited) uses inline sql and when i dump the values before the sql command is run i get dd/mm/yyyy for the app running 2005 and mm/dd/yyyy for the app on 2000. I'm trying to determine if this is an issue with the machine itself and the .net framework installed or infact the two different versions on sql server.
thanks
View 5 Replies
View Related
Jan 28, 2008
update tblPact_2008_0307 set student_dob = '30/01/1996' where student_rcnumber = 1830when entering update date in format such as ddmmyyyyi know the sql query date format entered should be in mmddyyyy formatis there any way to change the date format entered to ddmmyyyy in sql query?
View 5 Replies
View Related
May 12, 2006
Hello guys,
I have a column of integer data type that contains a millisecond data(for example 54013). I want to convert this value to the corresponding "hh:mm:ss" format. Can anybody help me with this issue?
Sincerely,
amde
View 4 Replies
View Related
Dec 5, 2007
I need to convert an integer value fo for example 1071123 to a date field. This value would represent 107 = Year 2007, 11 = Month November, 23 = 23rd day of month. So effectively this would translate to 2007-11-23 00:00.000.
I would like to do this in the Integration Services package. I am retrieving data from an AS/400 system to an SQL Server DB. I'm not sure if I can do this with the Derived Column object or is there a better way to achieve this conversion.
Please, can anyone shed some light on this for me?
Thanks
CdnGator (Jason)
View 4 Replies
View Related
Mar 18, 2008
I'm trying to filter out timestamps that land exactly at .000 milliseconds. (e.g. 2007-12-05 16:30:50.000) Do I have to convert the timestamp to a string first and then use the LIKE statement? If so, can somebody show me how. I'm pretty green to SQL but know the basics. Any help would be greatly appreciated!
View 2 Replies
View Related
Apr 19, 2008
Advance thanks ....... My table is TimeSheet:----------------------------------- CREATE TABLE [dbo].[TimeSheet]( [autoid] [int] IDENTITY(1,1) NOT NULL, [UserId] [int] NOT NULL, [starttime] [datetime] NOT NULL, [endtime] [datetime] NOT NULL, [summary] [nvarchar](50) NOT NULL, [description] [nvarchar](50) NULL, [dtOfEntry] [datetime] NOT NULL, [Cancelled] [bit] NULL) ON [PRIMARY] My Query is------------------ insert into timesheet (UserId, StartTime,EndTime, Summary, Description,DtOfEntry) values (2, '19/04/2008 2:05:06 PM', '19/04/2008 2:05:06 PM', '66', '6666','19/04/2008 2:05:06 PM')i m not able to insert value Error Message is-------------------------Msg 242, Level 16, State 3, Line 1The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.The statement has been terminated. can any body give any solution
View 5 Replies
View Related
Aug 3, 2005
Hey, I have a big problem that i wanna search data from SQL by DateTime like thatselect * from test where recorddate='MyVariableWhichHoldDate'i use variable that holds Date info.i searched a lot infomation on net but there is no perfect solution. i know why this occur but there is no function to solve this problem. i used a lot of ways. it accept yyyy-mm-dd format but my variable format is dd-mm-yyyyy . is there any function for this problem? and any other solution.thanks for ur attentionregards
View 6 Replies
View Related
Jan 22, 2008
I know what it means. The problem is that I can't see where it's happening. Looking at SQL Profiler shows the info correct. Front end code only allows max of 50 characters for the title, 2000 for the announcement. Expiration date is picked from a date picker, subgroupID and who are both 12 characters and are session info (this is correct as it's used else where and they are working).
This is from SQL Profiler:
exec ws_Admin_Announcements_AddlAnnouncement @subgroupid = 'D4F4CB571A09', @title = N'over 12 characters', @announcement = N'<p>test</p>', @expiration = 'Jan 22 2008 11:41AM', @who = 'D05B47F2CFB1'
Class:1 public int insertNewAnnouncement(string subgroupid, string title, string announcement, DateTime expiration,string who, string connectionString)
2 {
3 try
4 {
5 dbConnection = new SqlConnection(connectionString);
6 dbCommand = new SqlCommand("ws_Admin_Announcements_AddlAnnouncement", dbConnection);
7 dbCommand.CommandType = CommandType.StoredProcedure;
8 dbCommand.Parameters.Add("@subgroupid", SqlDbType.VarChar, 12);
9 dbCommand.Parameters[0].Value = subgroupid;
10 dbCommand.Parameters.Add("@title", SqlDbType.NVarChar, 100);
11 dbCommand.Parameters[1].Value = title;
12 dbCommand.Parameters.Add("@announcement", SqlDbType.NText);
13 dbCommand.Parameters[2].Value = announcement;
14 dbCommand.Parameters.Add("@expiration", SqlDbType.SmallDateTime);
15 dbCommand.Parameters[3].Value = expiration;
16 dbCommand.Parameters.Add("@who", SqlDbType.VarChar, 12);
17 dbCommand.Parameters[4].Value = who;
18
19 dbConnection.Open();
20 intRowsAffected = dbCommand.ExecuteNonQuery();
21 }
22 finally
23 {
24 dbCommand.Dispose();
25 dbConnection.Dispose();
26 }
27
28 return intRowsAffected;
29 }
SP1 CREATE PROCEDURE ws_Admin_Announcements_AddlAnnouncement
2
3 @subgroupid varchar(12),
4 @title nvarchar (100),
5 @announcement ntext,
6 @expiration smalldatetime,
7 @who varchar(12)
8
9 AS
10
11 insert into tblannouncements (fk_strsubgroupid,strtitle,strannouncement,dteexpires,dtecreated)
12 values (@subgroupid,@title,@announcement,@expiration,getdate())
13
Table Layout
fk_strSubGroupID varchar 12strTitle nvarchar 200strAnnouncement ntext 16dteExpires smalldatetime 4dteCreated smalldatetime 4
Any help would be greatly appreciated. Thanks ^_^
View 17 Replies
View Related
Feb 14, 2008
My SQL script: -
CREATE TABLE #temp_1
(LEGAL_ENTITY varchar(3) ,
DESCRIPTION varchar(25)
)
DECLARE
@select varchar(2000),
@from varchar(2000),
@where varchar(4000),
@final varchar(8000)
SELECT @select = 'SELECT LEGAL_ENTITY, DESCRIPTION'
SELECT @from = ' FROM table_1 WITH (NOLOCK)'
SELECT @final = @select+@from
INSERT INTO #temp_1
( LEGAL_ENTITY,
DESCRIPTION
)
EXEC (@final)
SELECT LEGAL_ENTITY, DESCRIPTION
From #temp_1
drop table #temp_1
By using above scrript, I will get a error message in SQL2005 database:-
Server: Msg 8152, Level 16, State 14, Line 1
String or binary data would be truncated.
I will not error in SQL2000
or
I comment exec(@final) and directly put in the SELECT statement, th
There is some SELECT statement modification in between that force me must use the variables to construct the SELECT statement. So can anyone advice, how to avoid the error?
Please advice, Thank you.
View 10 Replies
View Related
May 13, 2006
Hi,
I have a column of type datetime in sqlserver 2000. Whenever I try to insert the date
'31/08/2006 23:28:59'
I get the error "...datetime data type resulted in an out-of-range datetime value"
I've looked everywhere and I can't solve the problem. Please note, I first got this error from an asp.net page and in order to ensure that it wasn't some problem with culture settings I decided to run the query straight in Sql Query Anaylser. The results were the same. What else could it be?
cheers,
Ernest
View 2 Replies
View Related