1

I have a file with a timestamp with time format as 2017-01-20 16:53:05.212 (yyyy-MM-dd HH:mm:ss.SSS).

I have uploaded this file to Azure data lake gen 2 and accessed that file into Azure Databricks. But when I have executed the below simple query in Databricks notebook. Time format was getting changed to 2017-01-20T16:53:05.212+0000 (yyyy-MM-dd'T'HH:mm:ssZZZZ).

query:

Select * from dsd_file_temp

I don't want to change my time format.

James Z
  • 12,209
  • 10
  • 24
  • 44
sai m
  • 99
  • 1
  • 15
  • 2
    Dates in SQL and Python are binary values, they have no format. What you think is a different value format is actually a different *display* format. Besides, both formats are essentially the same, ISO8601. The full ISO8601 uses `T` as a separator between date and time but most applications omit it when displaying dates to users – Panagiotis Kanavos Jan 24 '22 at 08:00

1 Answers1

0

The default timestamp format in Azure databricks includes the time-zone.

enter image description here

You can use date_format() to get the required value.

select date_format(to_timestamp('2017-01-20 16:53:05.212'),'yyyy-MM-dd HH:mm:ss.SSS') as dt2;

enter image description here

NiharikaMoola-MT
  • 4,700
  • 1
  • 3
  • 15
  • Thanks for answering NiharikaMoola-MT. By doing above mentioned method. The format of column is changing to String type(timestamp to string). Can you say how can keep format as timestamp only. – sai m Jan 26 '22 at 10:22