Errors With DateTime Conversion -- This One's A Weird One.

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


ADVERTISEMENT

Weird Dtexec Errors

Jun 18, 2007



I receive the error below when running a package using dtexec. The package itself runs ok, however. That is, my data loads into the table.



All this package does is execute 3 separate Execute SQL tasks that are simple insert statements into a table.



There are NO script tasks or components in the package. So what is this weird error about?





Error: 2007-06-18 18:01:49.36
Code: 0xC0012024
Source: Script Task
Description: The task "Script Task" cannot run on this edition of Integration
Services. It requires a higher level edition.
End Error
Warning: 2007-06-18 18:01:49.36
Code: 0x80019002
Source: OnPostExecute
Description: The Execution method succeeded, but the number of errors raised
(2) reached the maximum allowed (1); resulting in failure. This occurs when the
number of errors reaches the number specified in MaximumErrorCount. Change the M
aximumErrorCount or fix the errors.
End Warning

View 4 Replies View Related

Help, Weird Int To Date Data Conversion

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

Weird Errors When Trying To Insert With IDENTITY_INSERT On!

Oct 30, 2006

SQL Server 2000 (DDL below)If I try to run this code in QA:SET IDENTITY_INSERT tblAdminUsers ONINSERT INTO tblAdminUsers(fldUserID,fldUsername,fldPassword,fldFullname,fldPermission,fldEmail,fldInitials,fldLastLogon,fldBatch)SELECTfldUserID,fldUsername,fldPassword,fldFullname,fldPermission,fldEmail,fldInitials,fldLastLogon,fldBatchFROM[BSAVA_26-10-2006].dbo.tblAdminUsersSET IDENTITY_INSERT tblAdminUsers OFFI get an error:IDENTITY_INSERT is already ON for table'BSAVA_Archive_Test_2006.dbo.GPS_CHAR'. Cannot perform SET operationfor table 'tblAdminUsers'.If I try to run:INSERT INTO tblAdminUsers(fldUserID,fldUsername,fldPassword,fldFullname,fldPermission,fldEmail,fldInitials,fldLastLogon,fldBatch)SELECTfldUserID,fldUsername,fldPassword,fldFullname,fldPermission,fldEmail,fldInitials,fldLastLogon,fldBatchFROM[BSAVA_26-10-2006].dbo.tblAdminUsersI get the error:Cannot insert explicit value for identity column in table'tblAdminUsers' when IDENTITY_INSERT is set to OFF.Anyone any ideas? FYI the tables I'm INSERTing into were scripted fromthe [BSAVA_26-10-2006] tables.TIAEdward=====================if exists (select * from dbo.sysobjects where id =object_id(N'[dbo].[tblAdminUsers]') and OBJECTPROPERTY(id,N'IsUserTable') = 1)drop table [dbo].[tblAdminUsers]GOif exists (select * from dbo.sysobjects where id =object_id(N'[dbo].[GPS_CHAR]') and OBJECTPROPERTY(id, N'IsDefault') =1)drop default [dbo].[GPS_CHAR]GOcreate default dbo.GPS_CHAR AS ''CREATE TABLE [dbo].[tblAdminUsers] ([fldUserID] [int] IDENTITY (1, 1) NOT NULL ,[fldUsername] [varchar] (20) COLLATE Latin1_General_CI_AS NULL ,[fldPassword] [varchar] (20) COLLATE Latin1_General_CI_AS NULL ,[fldFullname] [varchar] (50) COLLATE Latin1_General_CI_AS NULL ,[fldPermission] [smallint] NULL ,[fldEmail] [varchar] (50) COLLATE Latin1_General_CI_AS NULL ,[fldInitials] [varchar] (3) COLLATE Latin1_General_CI_AS NULL ,[fldLastLogon] [smalldatetime] NULL ,[fldBatch] [char] (1) COLLATE Latin1_General_CI_AS NULL) ON [PRIMARY]GO

View 10 Replies View Related

Weird DateTime Value

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

Send Mail Task In SSIS Weird Errors

Aug 31, 2006

Hey there all,



i am having a weird problem with the send mail task in SSIS. I have tried to different things, and i end up with two different errors:



Firstly, i have setup a data dump to excel, and the send mail taks emails this to specific email addresses.

In the Send mail task i have validated to SMTP server, and its correct.

I have manually entered all the information in the Send mail task, and i am sending to multiple email addresses. These are all seperated by a semi colan. I run the task and it fails on the send mail task with the follwoing error:

Error: 0xC002F304 at Send Mail Task, Send Mail Task: An error occurred with the following error message: "Unable to send to all recipients.".

Task failed: Send Mail Task

I have validated all the email address and they are correct. I did some searching and someone suggested to replace the semi colan with a comma. I do this and i get the follwoing error"

Error: 0xC002F304 at Send Mail Task, Send Mail Task: An error occurred with the following error message: "Mailbox unavailable. The server response was: 5.7.1 Unable to relay for rpwallis@bigpond.com.au".

I have checked that the IP for the SQL server is on the list of allowed relays on our exchange server. Does it make a difference if i am running this from Visual studio on my laptop?? by this, does it pick up the ip of my laptop when i test this or does it use the ip address of the server?? This would explain the relay message error if so..



Could someone please explain if i should use comma's or semi colans to seperate email addresses? and also lead me in the right direction in relatio to my problems..



Many thanks in advance



Scott Lancaster

View 3 Replies View Related

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 DATETIMESET @dTest='2001-1-1 1:1:1:991'SELECT @dTestSET @dTest='2001-1-1 1:1:1:997'SELECT @dTestSET @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.9902001-01-01 01:01:01.9972001-01-01 01:01:02.000Then what's the reason of this weird problem?

View 3 Replies View Related

Conversion Errors

May 5, 2008

Hello,

I have the following query that runs against a view:

select cast((convert(varchar, HD.Value)) as float)
from HardwareData HD
where (HD.PropertyName = 'Total Space' and HD.CategoryName = 'Disk Drive(s)')

This query works with no errors. When I add a where clause as follows, it breaks:

select cast((convert(varchar, HD.Value)) as float)
from HardwareData HD
where (HD.PropertyName = 'Total Space' and HD.CategoryName = 'Disk Drive(s)')
and cast((convert(varchar,HD.Value)) as float) > 9999999

I get a "Msg 8114, Error converting data type varchar to float." message. Why would the statement in the WHERE clause fail to convert to float and not the statement that's in the select statement? It's as if the where clause conversion is done against all of the data, not just against the subset specified by the first part of the where clause where I try to narrow it down by total space. Any ideas?

THANKS

View 10 Replies View Related

Help With A SQL Union Query Please. Conversion Errors!

Aug 29, 2007

Hi, I've created a SQL union query that grabs the top three values of a test and puts the results together on one line item by a recordnumber.
The only problem is, one value is generating the error: " Syntax error converting the varchar value '=' to a column of data type int."
This field is an operator field, so it will only display operator values ( <, >, = ).  Everything seems to work BUT the union join on that column, which is a varchar data type.  I need this union to work, and Im frustrated that I can't seem to figure out why I can't get the logic to work.  Can someone take a look at this and help me with it?
The union query looks like this:

exec('select
RecordNumber,Sum(rank1) as HbA1CRank1,max(Operator1) as HbA1COperator1,sum(contentValue1) as HbA1CContentvalue1,max(dos1) as HbA1CDOS1,Sum(rank2) as HbA1CRank2,max(Operator2) as HbA1COperator2,sum(contentValue2) as HbA1CContentvalue2,max(dos2) as HbA1CDOS2,Sum(rank3) as HbA1CRank3,max(Operator3) as HbA1COperator3,sum(contentValue3) as HbA1CContentvalue3,max(dos3) as HbA1CDOS3
from
(SELECT DISTINCT                       TOP 100 PERCENT recordnumber, Rank AS rank1, cast(Operator as varchar) as Operator1, contentValue AS contentvalue1, DOS AS DOS1, 0 AS rank2, 0 as Operator2,  0 AS contentvalue2, 0 AS DOS2,                       0 AS rank3, 0 as Operator3, 0 AS contentvalue3, 0 AS DOS3FROM         (SELECT     (SELECT     COUNT(*)                                               FROM         tblDiabetic_HgbA1C_Total vw1                                               WHERE     vw1.rECORDnUMBER = vw2.rECORDnUMBER AND vw1.ItemCode = vw2.ItemCode AND vw1.Operator = vw2.Operator AND vw1.DOS > vw2.DOS) AS Rank, *                       FROM          tblDiabetic_HgbA1C_Total vw2) vw3WHERE     (Rank = 0)ORDER BY RecordNumber
UNION
SELECT DISTINCT                       TOP 100 PERCENT recordnumber, 0 AS rank1, 0 as Operator1, 0 AS contentvalue1, 0 AS DOS1, Rank AS rank2, cast(Operator as varchar) as Operator2, contentValue AS contentvalue2, DOS AS DOS2,                       0 AS rank3, 0 as operator3, 0 AS contentvalue3, 0 AS DOS3FROM         (SELECT     (SELECT     COUNT(*)                                               FROM         tblDiabetic_HgbA1C_Total vw1                                               WHERE     vw1.rECORDnUMBER = vw2.rECORDnUMBER AND vw1.ItemCode = vw2.ItemCode AND vw1.Operator = vw2.Operator AND vw1.DOS > vw2.DOS) AS Rank, *                       FROM          tblDiabetic_HgbA1C_Total vw2) vw3WHERE     (Rank = 1)ORDER BY RecordNumber
UNION
SELECT DISTINCT                       TOP 100 PERCENT recordnumber, 0 AS rank1, 0 as Operator1,  0 AS contentvalue1, 0 AS DOS1, 0 AS rank2, 0 as operator2, 0 AS contentvalue2, 0 AS DOS2, rank AS rank3,  cast(Operator as varchar) as operator3,                      contentvalue AS contentvalue3, DOS AS DOS3FROM         (SELECT     (SELECT     COUNT(*)                                               FROM         tblDiabetic_HgbA1C_Total vw1                                               WHERE     vw1.rECORDnUMBER = vw2.rECORDnUMBER AND vw1.ItemCode = vw2.ItemCode AND vw1.Operator = vw2.Operator AND vw1.DOS > vw2.DOS) AS Rank, *                       FROM          tblDiabetic_HgbA1C_Total vw2) vw3WHERE     (Rank = 2)ORDER BY RecordNumber )tblHgA1C
group by RecordNumber
')GO
Can anyone help?  It looks right to me, I just can't figure out why the error keeps coming up =
Thank you!

View 4 Replies View Related

Character Conversion Errors SQL To Excel

Feb 5, 2008

Hopefully this is an easy one.

But in both the importexport utility and from SSIS. "#" become "." (aka pound to period) in column headers. So for example [# of errors] becomes [. of errors]. Now I truly do not ever remember having this issue before but then again I have don't remember having to construct field names with a various assortment of characters that are randomly strewn about as though someone discovered the symbol picker recently and had decided to employ it to make the a spreadsheet a more interesting place. Hence after a good day of time wasted. (as I considered doing an alter table after the sheets were put out.. and then thought better of it.) I seek guidence here. Thanks in advance.

View 2 Replies View Related

DTS To SSIS Conversion (ActiveX Script Has Compilation Errors)

Oct 12, 2015

I am re-writing old DTS packages(from sql 2005) to convert them to SSIS packages(sql 2014) and in one of the script task, the old activex script does not run.

The script is :

'************************
' Visual Basic ActiveX Script
'************************
Function Main()
mydate = now()
yrs = ""
mth = ""
mth = Month(mydate) - 1
yrs = Right(Year(mydate), 4)
If Month(mydate) = 1 Then mth = "12"

[code].....

Not sure how to proceed forward? I am quite new to package migration

View 0 Replies View Related

Conversion Datetime

Mar 17, 2008

Hello boyz and girlz,
 
Little question:
I want to write the current date and time into a database with following code:
 
Dim time As DateTime
 
time = DateTime.Now
 
connection.Open()
 
 
cmd.CommandText = "INSERT INTO tblOpmerkingen(Time )values('" + time + "')"
cmd.Connection = connection
 
But: My "time" is DD/MM/YYYY HH/mm/SS
and in my database time = MM/DD/YYYY HH/mm/SS
 
can somebody help me?
thanx

View 6 Replies View Related

Datetime Conversion

Jun 16, 2005

Hi,I tried to convert sql datetime to string (hh:mm:ss), or filetime, but i wasn't successful. Will somebody help me with my problem? I don't know how I can solve my problem really.Thank's

View 6 Replies View Related

Datetime Conversion

Feb 28, 2005

Hello, everyone:

How to convert '173515' to be datetime like "5:33:00 PM". Thanks.

ZYT

View 1 Replies View Related

Datetime Conversion

May 19, 2008

I have in text field (nvarchar) following date dd-mm-yyyy
and i would like to convert it to smalldatetime field
in format yyyy-mm-dd.

Is there any explicit way to do it?

thank you

View 1 Replies View Related

Datetime Conversion

Feb 16, 2006

Hi!

I want to get current date and subtract 14 days from that date and return result as int in yyyymmdd-format.
How should I do that?

Thanks in advance, Makkaramestari

View 2 Replies View Related

Datetime Conversion

Feb 6, 2007

hi, i need to convert datetime as dd/mm/yy hh:mi:ss:mmmAM format,so i used this:
select convert(varchar(20),getdate(),131)
19/01/1428 2:20:22:

i need 06/02/2007 2:20:22pm how to get please tel me

View 6 Replies View Related

Conversion From '%' To Datetime

Sep 11, 2007

hi,

i m facing a problem. I want to convert '%' into datetime format.
can any one provide me solution?

Thanx

View 7 Replies View Related

SQL 2012 :: Ignored Column In SSIS Package Throws Conversion Errors?

Dec 12, 2013

I have a data flow task in which I have a ADO NET source and OLE DB Destination. I have in the ADO NET source a sql command which pulls all the columns in a table. My requirement is to ignore a particular column,say column99. I opened advanced editor and deleted the mapping between the external and output columns for column99. I had also set the Error and Truncation to "Ignore Failure" for column99. I had also mapped the destination column to <Ignore> in OLD DB destination.

But this still throws the error-

Description: The ADO NET Source was unable to process the data. Field table-column99 missing an escape character for a quote.Unable to update PK WHERE clause.Error processing data batch.

How do I solve this?

View 9 Replies View Related

Data Conversion Errors On Excel Import Into Existing Table

Aug 28, 2006

Recently installed Sql Server 2005 client and am now attempting to import data from a spreadsheet into an existing table. This works fine with Sql Server 2000 but I am getting data conversion truncation errors that stop the process when this runs using import utility in Sql Server 2005.

Any help would be appreciated.

View 1 Replies View Related

Datetime Conversion Error?

Jan 17, 2008

 Hi,
I am getting the following error when
executing the ExecuteInsert in the code below..:
 
Conversion failed when converting
datetime from character string.



    private bool
ExecuteInsert(String quantity)   
{[snip]       
con.Open();       
SqlCommand command = new SqlCommand();       
command.Connection = con;       
TextBox TextBox1 =
(TextBox)FormView1.FindControl("TextBox1");       
Label 1 = (Label)FormView1.FindControl("Label3");       
Label 2 = (Label)FormView1.FindControl("Label13");       
command.CommandText = "INSERT INTO Transactions (etc,Date,etc)
VALUES (etc,@date,@etc)";        
command.Parameters.AddWithValue([snip]);       
command.Parameters.AddWithValue([snip]);        command.Parameters.AddWithValue("@date",
DateTime.Now.ToString());        
command.Parameters.AddWithValue([snip]);       
command.Parameters.AddWithValue([snip]);       
command.ExecuteNonQuery();       
con.Close();       
command.Dispose();       
return true;    }    protected
void Button2_Click(object sender, EventArgs e)   
{        TextBox TextBox1 =
FormView1.FindControl("TextBox1") as TextBox;       
bool retVal = ExecuteUpdate(Int32.Parse(TextBox1.Text));       
if (retVal)           
Response.Redirect("~/URL/EXTENSION.aspx");       
Insert();    }    private
void Insert()    {       
TextBox TextBox1 = FormView1.FindControl("TextBox1") as
TextBox;       
ExecuteInsert(TextBox1.Text);    }}  Thanks if someone can help!Jon

View 2 Replies View Related

Datetime And Conversion To Smalldatetime.

Jan 15, 2006

I am placing DateTime into SQL using an ASP.NET form. The date should be formatted dd/mm/yyyy hh/mm/ss.

I am getting the error below. Is there any way to convert the format of the DateTime function from the ASP.NET end?

Thanks

mes


"The conversion of char data type to smalldatetime data type resulted in an out-of-range smalldatetime value"

View 1 Replies View Related

Datetime Field Conversion

Aug 8, 2000

Hello, I would appreciate any suggestions
I've got a datetime field that I'd like to store as just the date without the time component, but still to keep it defined as a datetime field. I ran this update statement but this conversion isn't working. Conversion to char gives me what I want but I need to keep the field as a date datatype if possible.
Thanks :)

update
<table>
set
<column>=convert(datetime,convert(char(10),hire_date,101)) )

View 3 Replies View Related

Conversion Of Nvarchar To Datetime. Is This Possible??

Aug 22, 2000

The transaction_date is datetime and date1 is nvarchar.
When I run the script:
Insert into payment(transaction_date)
Select convert (datetime, date1) from dep01

I get the following message:

Server: Msg 8115, Level 16, State 2, Line 1
Arithmetic overflow error converting expression to data type datetime.
The statement has been terminated.

Thanks in advance, Mike

View 1 Replies View Related

Datetime Conversion From Csv File

Jul 19, 2004

I have a DTS-package running which imports data from a .csv file to a sql2000 database.
In the file there are some datefields in dd/mm/yyyy format and i want to keep it that way. But after the import the dateformat is yyyy/mm/dd.
Does anybody know how i can prevent this from happening?

Thanks in advance

View 1 Replies View Related

Float To Datetime Conversion

Aug 3, 2007

I need to convert values in a float data type field to that of datetime. The float data type field currently contains values such as 20060927,20060928, etc. Any suggestions?

Thanks in advance,
sajmera

View 3 Replies View Related

String To Datetime Conversion

May 30, 2008

Hi,
Ive imported a data set into SQL. Now on redefining a text field to datetime, most dates that are filled come through okay.

The issue is that there are some empty fields which I'd like for it to stay empty after conversion. Now what happens is that the empty field becomes '01/01/1900' - which is throwing off our queries as we need it to be compared to other date fields.

Is there a way to keep it empty even after the datatype is changed to datetime?
Thanks a bunch!

View 5 Replies View Related

Conversion Char To Datetime

Feb 6, 2007

Hi all,

I need to convert a char (a) to datetime in the following query:

select *
from table1
where convert (a, datetime) > '01/31/2007'

this query does not work :(

View 1 Replies View Related

Conversion Datetime To String

Jul 20, 2006

Hi
Can we convert DateTime to String. If so how?
Thanks in advance.

Mahathi.

View 1 Replies View Related

CONVERSION FROM CHAR(4) TO DATETIME

Nov 23, 2006

i have another problem.and it's now on converting a char(4) to datetimehere is the situationJ_TIM < F_TIMJ_TIM is datetime while F_TIM is char of 4exampleJ_TIM = 20:30F_TIM = 2030how can i convert F_TIM to datetime so that i can compare them.???thanks

View 3 Replies View Related

Error In Datetime Conversion

May 21, 2008

Hi everyone,

I have a problem with a datetime field.
In the database is stored as datetime (121 format) ex. 2008-05-20 17:30:00.000
I have a simple select query (no datetime conversions used) and the result I get from the report looks like 5/20/2008 5:30 PM.

I dont want this format so i use this custom dd:MM:yyyy hh:mms

After that i get the dates like this 5/20/2008 5:30 instead of 17:30.

Any suggestions appreciated...



View 1 Replies View Related

DT_DBTIME To DateTime Conversion

May 21, 2007

I have a column of DT_DBTIME data type in my Flat File source. This column is mapped to DateTime column in the SQL server destination table. A problem is that time values '12:06:39' and '13:37:45' are converted to the dates '12/30/1899 12:06:39 PM' and '12/30/1899 1:37:45 PM' correspondingly.


When I try the similar conversion from the inside Server Management Studio :

SELECT CAST('12:06:39' as DateTime), CAST('13:37:45' as DateTime)



I get the following results:

'1900-01-01 12:06:39.000' and '1900-01-01 13:37:45.000'



As you can see, the date portion is different and I expect that January 1st, 1900 is correct for this conversion. So, my questions are:

1. Why I have "previous" day in the Integration Services transformation?

2. How to fix this problem?



Thank you,

Vlad

View 3 Replies View Related

Datetime Conversion Question

May 1, 2007

If I have a variables that are declared as



@Start_Year int

@Start_Month int



How do I convert those variables to datetime format of

MM/1/YYYY

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved