October 22, 2014 at 7:09 am
hi,
I want to know is it is possible to convert an int to date in a table.
When I run ALTER TABLE dbo.nomtable ALTER COLUMN datefield DATE
I have an error message:
Operand clash: int is incompatible with time
October 22, 2014 at 7:26 am
Not directly, because there's no implicit conversion possible from INT to DATE.
What you can do is to add a new column with a DATE type, update it with the converted form of the INT then drop the old INT column and rename the new one.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
October 22, 2014 at 9:31 am
I still got the same problem, when i try to update the new field , i got the same message
ALTER TABLE DBOOKING ADD TAMPON DATE NULL
UPDATE DBOOKING SET TAMPON=DATEDELETE
Msg 206, Level 16, State 2, Line 1
Operand type clash: int is incompatible with date
October 22, 2014 at 10:35 am
If your int looks like 20141022 (for today's date), you need to convert it to char(8) and then to date. If it's a numeric value representing the date as 41932 (in SQL Server) or 41934 (in Excel), you need to find out the correct way to convert it.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply