error is : Invalid timestamp: '2/17/2022'
Hi guys, Someone can help me to change STING (dd-mm-yyy) to a Date fomat (yyyy-mm-dd)?
thank you for your time
Try below
select parse_date('%m/%d/%Y', '2/17/2022'), parse_date('%m-%d-%Y', '2-17-2022')
with output
Related
I am trying to convert a timestamp string to timestamp with date_parse, but keep getting an error. Any suggestions? I am working on Presto SQL. I have tried to replace %H:%f with %T and it still doesn't work.
date_parse(sg."#timestamp", '%Y-%m-%d %H:%f')
The error message is:
presto: query failed (200 OK): "USER_ERROR: com.facebook.presto.spi.PrestoException: Invalid format: "2017-12-31 08:29:02.12" is malformed at ":02.12""
Any help would be greatly appreciated, thanks!
You need date_parse() with this format:
presto:default> SELECT date_parse('2017-12-31 08:29:02.12', '%Y-%m-%d %H:%i:%S.%f');
_col0
-------------------------
2017-12-31 08:29:02.120
(1 row)
I have a column 'appointment_date' in string formate representing a date dd.mm.yyyy.
In BiqQuery I am using the following query to find all appointments dates lying in the future:
SELECT appointment_date
FROM `appointments`
where parse_date('%d.%m.%Y', appointment_date) > current_date()
BiqQuery returns the following error message: Failed to parse input string ""
Please advice.
Thanks,
Janine
Use safe.parse() to avoid the error:
where safe.parse_date('%d.%m.%Y', appointment_date) > current_date()
This will return NULL for invalid formats rather than an error.
I have this date format in hive: 20180618151752
Make the following query to leave it in the following way:
select
concat(substr(xdr.time_stop,1,8),' ',
substr(xdr.time_stop,9,2),':',
substr(xdr.time_stop,10,2),':',
substr(xdr.time_stop,11,2)) as date
from padl.fraude_vozm_xdr;
20180618 18:17:52
Now, I need to convert that string field to date, how could I do it?.
Thank you
Use from_unixtime and unix_timestamp.
from_unixtime(unix_timestamp('20180618151752','yyyyMMddHHmmss'),'yyyyMMdd HH:mm:ss')
I am trying to extract only date from a timestamp of the following type:
2015-01-01-15:00:02:30
I tried only using cast() but it gave me an error:
':' is undefined symbol
Can I get some assistance here? Help is greatly appreciated.
You can use convert() and left()
select convert(date,left('2015-01-01-15:00:02:30',10))
select cast(left('2015-01-01-15:00:02:30',10) as date)
in Teradata SQL I need convert a string to date.
Currently the string looks like this: 2017-02-28T14:41:32.817Z
But I need it in this format as DATE: DD.MM.YYYY HH:SS
Any idea how to do this? Whenever I try to cast, I get the error 2666 ( Invalid date supplied for mytable.mycolumn)
Hope someone can help!
Best regards,
Both input and expected result are timestamps, not dates.
SELECT '2017-02-28T14:41:32.817Z' AS mycol,
-- string to timestamp
Cast(mycol AS TIMESTAMP(3)),
-- back to string with a different format
To_Char(Cast(mycol AS TIMESTAMP(3)), 'DD.MM.YYYY HH:SS')