Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 MySQL CAST

Author  Topic 

tranquilraven
Starting Member

19 Posts

Posted - 2012-06-24 : 14:23:34
Could someone enlighten me as to why this CAST function won't work in MySQL? Thank you in advance.

SELECT OrderNumber, OrderDate, ShipDate, CAST(ShipDate - OrderDate AS INTEGER) AS DaysElapsed
FROM Orders

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-06-24 : 14:36:13
would be better off posting it in MySQL forum. This is MS SQL Server forum

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2012-06-26 : 05:33:12
Are you trying to find out day difference? Mysql doesnot support CASTing to integer. Use Signed

SELECT OrderNumber, OrderDate, ShipDate, CAST(ShipDate - OrderDate AS SIGNED) AS DaysElapsed
FROM Orders


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -