MySQL Forums
Forum List  »  General

Re: min/max function result datatype
Posted by: Vladyslav Zamashka
Date: May 09, 2019 01:11AM

I have table orders with field OrderDate, the datatype is DateTime

select min(`orders`.`orderdate`) FROM `orders` AS `orders` - return date with Datetime datatype

select min(TIMESTAMP(MAKEDATE(year(`orders`.`orderdate`),1))) FROM `orders` AS `orders` - resturn string datatype.

select TIMESTAMP(MAKEDATE(year(`orders`.`orderdate`),1)) FROM `orders` AS `orders` - resturn datetime datatype.

DDL:

CREATE TABLE `orders` (
`OrderID` int(11) DEFAULT NULL,
`CustomerID` varchar(5) DEFAULT NULL,
`EmployeeID` int(11) DEFAULT NULL,
`OrderDate` datetime DEFAULT NULL,
`RequiredDate` datetime DEFAULT NULL,
`ShippedDate` datetime DEFAULT NULL,
`ShipVia` int(11) DEFAULT NULL,
`Freight` float DEFAULT NULL,
`ShipName` varchar(40) DEFAULT NULL,
`ShipAddress` varchar(60) DEFAULT NULL,
`ShipCity` varchar(15) DEFAULT NULL,
`ShipRegion` varchar(15) DEFAULT NULL,
`ShipPostalCode` varchar(10) DEFAULT NULL,
`ShipCountry` varchar(45) DEFAULT NULL,
`Invoiced` bit(1) DEFAULT NULL,
`AdHocUserName` varchar(15) DEFAULT NULL)

Options: ReplyQuote


Subject
Written By
Posted
Re: min/max function result datatype
May 09, 2019 01:11AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.