dbTalk Databases Forums  

How to Compare Date Time

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss How to Compare Date Time in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Henry
 
Posts: n/a

Default How to Compare Date Time - 07-15-2003 , 04:27 AM






Hi,

I want to Compare the Date time by the following VB Script
code:

-----------------------------------------------------------
Function Main()
if (DTSSource("Time").Value < "8/8/1754") then
DTSDestination("Time") = "2/2/2079"
else
DTSDestination("Time") = DTSSource("Time")
end if
Main = DTSTransformStat_OK
End Function
-----------------------------------------------------------

This works fine, but if I change "8/8/1754"
to "10/10/1754", or change "2/2/2079" to "8/8/2079"it
gives me an error:
-----------------------------------------------------------
"Insert error, ('Time',DBTYPE_DBTIMESTAMP), status 6: Data
overflow. Invalid character value for cast specification"
-----------------------------------------------------------

I am really confused, can anyone help me.

Henry

Reply With Quote
  #2  
Old   
Adrian
 
Posts: n/a

Default How to Compare Date Time - 07-22-2003 , 06:07 AM






Dear Henry,
porbably you are using as destination field a
smalldatetime datatype, I am supposing this because if you
are looking in the documentation for datetime and
smalldatetime datatype you will find the information: The
smalldatetime data type stores dates and times of day with
less precision than datetime. SQL Server stores
smalldatetime values as two 2-byte integers. The first 2
bytes store the number of days after January 1, 1900. The
other 2 bytes store the number of minutes since midnight.
Dates range from January 1, 1900, through June 6, 2079,
with accuracy to the minute.

you can rund the scripts in SQL Query Analizer

declare @dtmDate smalldatetime
set @dtmDate = '06/06/2079'
select @dtmDate

declare @dtmDate smalldatetime
set @dtmDate = '06/07/2079'
select @dtmDate

the first one works without problems, the second returns
an error. So if you are changing the datatype of the
destination field id should be ok I think.
Usual in order to compare two dated can be used the
function DateDiff. For more information see the
documentation.
I hope this helps.
Best regards,
Adrian

Quote:
-----Original Message-----
Hi,

I want to Compare the Date time by the following VB
Script
code:

----------------------------------------------------------
-
Function Main()
if (DTSSource("Time").Value < "8/8/1754") then
DTSDestination("Time") = "2/2/2079"
else
DTSDestination("Time") = DTSSource("Time")
end if
Main = DTSTransformStat_OK
End Function
----------------------------------------------------------
-

This works fine, but if I change "8/8/1754"
to "10/10/1754", or change "2/2/2079" to "8/8/2079"it
gives me an error:
----------------------------------------------------------
-
"Insert error, ('Time',DBTYPE_DBTIMESTAMP), status 6:
Data
overflow. Invalid character value for cast specification"
----------------------------------------------------------
-

I am really confused, can anyone help me.

Henry
.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.