Formatting date iso 8601 date format with Time zone - formatting

I am using a format string yyyy-MM-dd'T'HH:mm:ss
and its working great for dates like: 2014-02-20T05:25:03
What should be the format string when adding timezone like: 2014-02-20T05:25:03-07:00
Or 2014-02-20T05:25:03.366+05:00

Related

Convert 'yyyymmddhhmmss' to MM/DD/YYYY HH:MM (AM/PM) in Snowflake

I would like to convert a String containing values in the format yyyymmddhhmmss to MM/DD/YYYY HH:MM (AM or PM) in Snowflake. The String contains time in UTC format. Also would like the final output to be in CST timezone.
Eg of String : 20220120035900
Expected output : 01/20/2022 03:59:00
Appreciate the help!
Please check below select try_to_timestamp('20220120035900', 'YYYYMMDDHHMISS');
UTC to CST:
SELECT try_to_timestamp('20220120035900', 'YYYYMMDDHHMISS') as t_str,
t_str::timestamp_ntz as UTC_tz,
convert_timezone('UTC','America/Chicago', UTC_tz) chicago_time;

SQLite date function returns nothing

I have a dataset with column named "msg_dateStr" which contains user's accessing date and time.
I tried to split it into two different columns; date and time, and I did SELECT date(msg_dateStr, 'localtime') as Year
but it returns null straight.
I don't know why this happens and how I can make sure something went wrong.
Any advice will be appreciated.
The date to be used by the Date and Time Functions such as date MUST be in a format that is recognised by SQLite for a useful result. Recognised formats are (extract from the link above) :-
Time Strings
A time string can be in any of the following formats:
YYYY-MM-DD
YYYY-MM-DD HH:MM
YYYY-MM-DD HH:MM:SS
YYYY-MM-DD HH:MM:SS.SSS
YYYY-MM-DDTHH:MM
YYYY-MM-DDTHH:MM:SS
YYYY-MM-DDTHH:MM:SS.SSS
HH:MM
HH:MM:SS
HH:MM:SS.SSS
now
DDDDDDDDDD
You need to ensure that the data is saved accordingly or alternately (but not recommended at all) reformat the column via SQL (e.g. using the substr built-in function).

Hive-- change partition format

I have some data that I'm currently partition by date, but hive's date format is "YYYY-MM-DD" and I need to convert that to the european format which is "DD/MM/YYYY"
Is there a way to do it?

Changing date format from day of year format (DDDYYYY) to Date Format (MM/DD/YYYY)

Trying to convert data thats in DDDYYYY (i.e. 1112014) to a standard date format (Feb-02-2014). How would i go about doing this? I know how to do the inverse operation but I was unable to find any examples online of how to convert from DDDYYYY format to MM/DD/YYYY format.
Below is my attempt:
select to_date(to_char(1112018, 'DDDYYYY'), 'MM/DD/YYYY') from dual;

Hive- Extract timestamp and date in defined format

I have column value in my HIVE table in String format like 20160921091213 i.e. YYYYMMDDHHMMDD. In target I have two columns one timestamp and other date column. I want to extract the same in the format for timestamp "YYYY-MM-DD HH24:MI:SS" and for date in the format "YYYY-MM-DD".
What can be the possible SQL for that.
convert to unix timestamp format and then convert back to string.
from_unixtime(unix_timestamp('20160921091213', 'yyyyMMddHHmmss'),'yyyy-MM-dd HH:mm:ss')
Result: 2016-09-21 21:12:13