How to convert string to date format in Tableau - tableau-api

I want to parse the following string
Wed Nov 18 20:22:45 +0000 2015
to date and time format in Tableau. Any idea how to use calculated fields? Tableau using the calculated field and DATEPARSE function?
Thanks

Try this:
Dateparse('EEE MMM dd hh:mm:ss Z yyyy', [YourString])
refer to http://userguide.icu-project.org/formatparse/datetime for a full list of parameters to specify your date.

Related

Tableau Date function and Y0Y comparsion

I have Column that is in String format such as 2018-03 and I want to convert this to Date format in tableau. Once I have convert these 4 years data I want to compare 2019 data with 2018 and 2021 data with 2020s
To convert to a date use the DATE function:
DATE(LEFT([DateField],5)+RIGHT([DateField],2)+"01")
Check here to see 2 different ways to do YoY - do whichever works better for your use case.
Assuming that 03 in your date 2018-03 corresponds to month, you can convert the string column to date column with the following calculation, where my_date is your string column
DATE(DATEPARSE("yyyy-MM", [my_date]))
See the results
Note, if however, 03 is quarter, use this calculation instead
DATE(DATEPARSE("yyyy-qq", [my_date]))

Redshift to_date issue: Invalid date format; Specified day twice

I am trying to convert a string to date in Redshift.
select to_date('Fri Apr 03 00:00:07 2020','Dy Mon DD hh24:mi:ss YYYY')
I am getting an issue Invalid operation: Invalid date format: Specified day twice.
Is it not possible to mention both Day name and Day of month as a number in the same date string?
I am following this reference for date formats in Redshift
So you are specifying the date twice in your format string - day of week and day of month. Which is Redshift to use if they are in conflict? The reference you provided is general in nature, specifying both input and output format patterns (converting to a string you may want both date and day of week). If you just want to ignore the day of the week in the input string just use the format string 'XXX Mon DD hh24:mi:ss YYYY'.

Netezza how read date time from character in the format of MON DD YYYY hh:mi am. I am getting an invalid date

In Netezza I have a field which contains characters which represents dates in the format of (I'm guessing) 'MON DD YYYY hh:miam'
select distinct nbr_cust
,as_of_date
,to_date(as_of_date,'Mon DD YYYY') as asOfDate
from MyNetezzaTable
Sample of the as_of_date
Jul 2 2018 4:30PM
Mar 6 2017 6:32PM
Feb 2 2016 12:58PM
Mar 31 2014 5:18PM
Jun 4 2018 6:55PM
I've tried to convert with to_date, and to_timestamp without any luck.
I keep getting an Invalid Date
Cause
The problem is the single digit hour. If the date string.
Resolving the problem
If it is not possible to ensure that the input strings always provide two digits for the hour value, you can use "FM" (fill mode) modifier in the template pattern. The “FM” prefix provides missing leading zeros. This SQL inserts the original string without error:
to_date(as_of_date,'Mon DD YYYY FMHH12:MIAM') as asOfDate

Convert "Fri Apr 29 06:01:46 EDT 2016" to date format in HIVE?

I have a collected a bunch of tweets and loaded into Hive table. The time for each tweet is of the format "Fri Apr 29 06:01:46 EDT 2016". I would like to aggregate on only date i.e 04/29/2016.
Are there any functions that would help me get this format? Or should I do a substring to get year, month, date separately and collate them?
Any help is much appreciated, thanks in advance.
You need to use the built in date functions for this. Please find below the function usage for your case :
from_unixtime(unix_timestamp('Fri Apr 29 06:01:46 EDT 2016','EEE MMM dd hh:mm:ss z yyyy'),'MM/dd/yyyy')
The code snippet:
select from_unixtime(unix_timestamp('Fri Apr 29 06:01:46 EDT 2016','EEE MMM dd hh:mm:ss z yyyy'),'MM/dd/yyyy');
UPDATE
Refer this for the hive builtin date time UDFs.
And this for the timestamp formatting strings.

ApI blueprint Date format

I have problem understanding the following date formate from apiblueprint tutorial
2016-02-05T08:40:51.620Z
I now 2016 is the year 02 is the month 05 is the date and 08:40:51 is the time but I dont understand the last part .620Z.
Can some one explain it for me. I wanted to find out AM or PM of the time using javascript from the date using javascript and not sure whether the formate is 12 or 24 hours.
Thanks
First of all, API Blueprint doesn't require you to use any particular Date format; you are free to use whatever you want to.
The format used in the tutorial is the standard ISO 8601 format: .620 is the number of miliseconds, and Z designates a Zulu timezone, meaning UTC.