You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@drill.apache.org by sa...@yahoo.com.INVALID on 2017/01/18 15:18:05 UTC

Converting Date to Timestand

Hello I am using Drill latest version (1.9) in window in embedded mode.
I am trying to convert Date to Timestand. While Coverting I am using following query:-
SELECT  T5.`Name` AS `Website Name`,  T5.`Description` AS `Description`,TO_CHAR((CAST(T5.`CreateOn` AS TIMESTAMP)), 'MM-dd-yyyy hh:mm:ss a') AS `CreateOn` FROM <plugingName>.<schemaName>.<tableName1> AS T4 INNER JOIN <plugingName>.<schemaName>.<tableName2>AS T5 ON T5.`ID` = T4.`WebsiteID`
NOTE:- IN MY DATABASE CREATEDON DATA IS LIKE  2017-01-05 08:09:17.020
O/p:- If I used this query CreatedOn Column Converted Successfully, but My WEBSITENAME Columns showing null values.. Website Name Description CreateOnnull  Hoostonicsas  01-05-2017 08:09:17 AMnull  Horotonicssd 01-05-2017 08:09:17 AMnull  Hodsodtonics  01-05-2017 08:09:17 AMnull  Hodtotonics  01-05-2017 08:09:17 AMnull  Hooewrtonics  01-05-2017 08:09:17 AMnull  Hohhotonics  01-05-2017 08:09:17 AM
But I remove TO_CHAR((CAST(T5.`CreateOn` AS TIMESTAMP)), 'MM-dd-yyyy hh:mm:ss a') AS `CreateOn` Column from Select query Output showing fine.
Please Tell me what i am doing wrong? And How to Convert (2017-01-05 08:09:17.020) data to (01-05-2017 08:09:17 AM).??

Re: Converting Date to Timestand

Posted by Muhammad Gelbana <m....@gmail.com>.
I'm not sure what's wrong but I'm sure that formatting your email a little
bit will make it much easier for everyone to read it. Like separate the log
message from the query and from your statements.

*---------------------*
*Muhammad Gelbana*
http://www.linkedin.com/in/mgelbana

On Wed, Jan 18, 2017 at 5:18 PM, <sa...@yahoo.com.invalid> wrote:

> Hello I am using Drill latest version (1.9) in window in embedded mode.
> I am trying to convert Date to Timestand. While Coverting I am using
> following query:-
> SELECT  T5.`Name` AS `Website Name`,  T5.`Description` AS
> `Description`,TO_CHAR((CAST(T5.`CreateOn` AS TIMESTAMP)), 'MM-dd-yyyy
> hh:mm:ss a') AS `CreateOn` FROM <plugingName>.<schemaName>.<tableName1>
> AS T4 INNER JOIN <plugingName>.<schemaName>.<tableName2>AS T5 ON T5.`ID`
> = T4.`WebsiteID`
> NOTE:- IN MY DATABASE CREATEDON DATA IS LIKE  2017-01-05 08:09:17.020
> O/p:- If I used this query CreatedOn Column Converted Successfully, but My
> WEBSITENAME Columns showing null values.. Website Name Description
> CreateOnnull  Hoostonicsas  01-05-2017 08:09:17 AMnull  Horotonicssd
> 01-05-2017 08:09:17 AMnull  Hodsodtonics  01-05-2017 08:09:17 AMnull
> Hodtotonics  01-05-2017 08:09:17 AMnull  Hooewrtonics  01-05-2017 08:09:17
> AMnull  Hohhotonics  01-05-2017 08:09:17 AM
> But I remove TO_CHAR((CAST(T5.`CreateOn` AS TIMESTAMP)), 'MM-dd-yyyy
> hh:mm:ss a') AS `CreateOn` Column from Select query Output showing fine.
> Please Tell me what i am doing wrong? And How to Convert (2017-01-05
> 08:09:17.020) data to (01-05-2017 08:09:17 AM).??