Re: Data Type conversion from int to datetime
From: Dan Guzman (guzmanda_at_nospam-online.sbcglobal.net)
Date: 11/03/04
- Next message: Dan Guzman: "Re: Use a Parameter as the name of a table in a Stored Procedure"
- Previous message: Jonathan Chong: "Re: Combine 2 tables into single resultset"
- In reply to: Guest: "Data Type conversion from int to datetime"
- Next in thread: Guest: "Re: Data Type conversion from int to datetime"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 2 Nov 2004 23:00:08 -0600
> CAST(tblSiteVisit.intDateStart AS DATETIME)
This conversion assumes the integer contains the number of days since
'1900-01-01'. If your integer contains a date value such as 20041102,
you'll need to first convert it to character and then to datetime. For
example:
SELECT CAST(CAST(tblSiteVisit.intDateStart AS char(8)) as datetime)
-- Hope this helps. Dan Guzman SQL Server MVP "Guest" <Guest@aew_nospam.com> wrote in message news:OXJVMzUwEHA.2876@TK2MSFTNGP12.phx.gbl... i have a datetime field that i want to calculate to equal those values in another field of dates as type integer. I had read somewhere that this would be an implicit conversion but it won't go. I've tried both CAST and nested CAST queries using various intermediate datatypes to get the conversion, but same results. Suggestions greatly appreciated. UPDATE tblMaterial SET tblMaterial.dtIDDate = CAST(tblSiteVisit.intDateStart AS DATETIME) FROM tblSiteVisit INNER JOIN tblMaterial ON tblSiteVisit.intSiteVisitID = tblMaterial.intSiteVisitID WHERE tblMaterial.dtIDDate IS NULL Arithmetic overflow error converting expression to data type datetime. The statement has been terminated. User submitted from AEWNET (http://www.aewnet.com/)
- Next message: Dan Guzman: "Re: Use a Parameter as the name of a table in a Stored Procedure"
- Previous message: Jonathan Chong: "Re: Combine 2 tables into single resultset"
- In reply to: Guest: "Data Type conversion from int to datetime"
- Next in thread: Guest: "Re: Data Type conversion from int to datetime"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|