Tableau cannot recognize timestamp field in my log file - tableau-api

I am using Tableau 9.3 to do a preliminary data analysis on one of my log file, the log file is like below:
"199.72.81.55",01/Jul/1995:00:00:01,/history/apollo/,200,6245,Sat
As you can see, there is a datetime for timestamp
In Tableau, initially it is recognized as a string like below:
That's fine, I want to make the field into datetime, and Tableau seems failed on it:
Why? How do I fix it?
Thank you very much.
UPDATED: after applying the formula suggested below, Tableau still cannot recognize the timestamp, here is the screenshot:
UPDATED AGAIN: after tested by nick, it is confirmed his first script is correct and working on his Tableau, why it fails on mine, I don't know, you are welcome to share any clue please, thank you.

Tableau implicit conversions are limited to more standard formats. You can still create a DATETIME field from your timestamp string using a calculated field with the following formula:
DATEPARSE('dd/MMM/yyyy:HH:mm:ss',[timestamp])
Using the above will transform a string like 01/Jul/1995:00:00:01 to a date and time of 7/1/1995 12:00:01 AM
Output using example data:

Sometimes the "date parse" function in Tableau doesn't quite do the job.
When this happens it is worth testing manual string manipulation with your timestamp field to put it into ISO-standard format and only then trying to convert it into a date. ISO format is yyyy-mm-dd hh:mm:ss (eg 2012-02-28 13:04:30). It is common to find that the original string has spurious characters or spaces that throw dateparse. But these are usually easy to manipulate away with suitable text manipulations. This can sometimes be longwinded, but it always works.

It turned out to be the region setting issue, it works after I switch it to USA

Related

BigQuery Date Conversion From String

I've looked everywhere and can't find this answer. It's a pretty simple query, but I can't for the life of me figure out how to change the date.
I have a date coming in as a string, but it's not being picked up. The date is being brought in as 20170601 but I need it to be in a date format to be picked up in Tableau. I'm using Standard SQL and have tried to PARSE_DATE("%x", date) as parsed, cast(date as date), etc. and I keep getting Error: Failed to parse input string "20170918" or some variation of that error.
#standardSQL
SELECT
visitorid,
parse_DATE("%x", date) AS parse
FROM google.com:analytics-bigquery.LondonCycleHelmet.ga_sessions_20130910
The table is within `
Please advise!!
You could try doing a regex replacement to build the date string which you require:
SELECT
REGEXP_REPLACE('20170601', r"^([0-9]{4})([0-9]{2})([0-9]{2})", "\\1/\\2/\\3")
This would output 2017/06/01, which perhaps is the format you require. Actually, I don't know what format Tableau is expecting, but YYYYMMDD is usually the correct order for a date, because it will sort correctly as text. You may use any replacement you want, using the above query as an example.

Tableau String to Date Time Format Issues

I am pulling in date information via MySQL and the date is in the string format of "MM/dd/YY hh:mm:ss"
Using the built in conversion to date isnt working; so I tried using DATEPARSE and also using DATE and manually parsing it. I have had no luck and I have no idea why I keep getting "null" as the answer or it is putting the month as year, day as month, and year as day.
See screenshots below for the different formulas I have used:
DATEPARSE
Original date format
DATE with manual parsing
This worked for me using your example original data
DATEPARSE('mm/dd/yy hh:mm:ss',[Time] )
I used tableau's documentation of custom date formats to find the right formula for the format.
If this doesn't solve the problem then it is most likely due to a Locale issue. The Dateparse function relies on the locale specified by your computer settings to interpret and then display the strings you want to convert and can affect whether a certain format can be specified. This means that if a certain format is not recognised it will return a null. This will often occur is the windows region and language format is changed to another language other than the original language the workbook was created it.
So check your locale and if required execute the following workaround (documented by tableau here):
Open Windows control panel > region and language > format
Click format dropdown and change to original language of workbook creation
click ok or apply and reopen tableau work book

SAS proc sql - Convert ddmmmyyyy to week-yr and month-yr

I have imported some data into SAS from some Excel spreadsheets sent to me. When I view the output from the imported table, the date appears as "01APR2014" and maintains chronological order. When I view the column properties the type is "Date" and the length is 8. Both the format and informat are DATE9.
I need to be able to convert this date to week-year and month-year, but no matter what I try I always get Jan, 1960.
Using proc sql, I used the below to get the week-year,
"(put(datepart(a.fnlz_date),weeku3.))|| "-" ||(put(datepart(a.fnlz_date),year.)) as FNLZD_WK_YR,"
but all I got was "W00-1960". I've used the formula above successfully many times before with SAS datetime values.
For month-yr, using proc sql, I tried
"datepart(a.fnlz_date) as DT_FNLZD format=monyy.,"
but the only value returned is "JAN60".
I also tried using SUBSTR, but got an error saying it requires a character argument, so SAS must see it as a number at least.
My question; does anyone know a way to get the week-yr and/or month-yr from this format? If so, how? I'm not opposed to using a data step, but I haven't been able to get that to work either.
Thanks in advance for any help or insight provided.
datepart converts datetimes to dates. Not helpful here.
If you're just displaying this, then you have a few options, particularly for month. You can just change the format of the variable (This changes what's displayed, but not the underlying value; consider this a value label).
When you use this like this (again, it looks like you got most of the way there):
proc sql;
select datevar format=monyy5. from table;
quit;
Just don't include that datepart function call as that's not appropriate unless you have a datetime. (Date=# of days since 1/1/1960, Datetime = # of seconds since 1/1/1960:00:00:00).
That will display it with MONYY5. format, which would be MAY10 for May, 2010. You have some other format options, see the documentation on formats by category for more details.
I can't think of a Week format that matches what you want (there are week formats, like WEEKW., as you clearly found, but I don't know that they do exactly what you want. So, if you want to build one yourself, you can either build a custom picture format, or you can make a string.
Building a custom picture format isn't too hard; see the documentation on Picture formats or google SAS Date Picture Format.
proc format;
picture weekyear (default=8)
low-high = 'W%0U-%Y' (datatype=date) ;
quit;
Now you can use that as a normal format.
To get at the week/etc. to build values, you can also use functions week(), month(), etc., if that's easier.
Since the data was already in a date format, I only needed to drop the DATEPART function that only works with datetime values. So, for month-yr,
"a.fnlz_date as fnlz_mnth format=monyy.,"
gives me the results I'm looking for.
Cheers!

How did this number become this datetime?

We have a vendor which one field in the database is a number and somehow in the app interface it shows the date,
I'm trying to figure out how is this conversion
Here is the data:
this number 15862 generates this date 06/05/2013
I have no idea how, the vendor told us it is NOT a custom logic conversion it was used a tsql function although I can't figure which one.
I tried using "convert" without success.
I don't think that's from a tsql function considering it's derived using the UNIX time epoch. Basically it's number of days since 1969-12-31
But you could get it using tsql like so:
select datediff(d,'1969-12-31','2013-06-05')
It looks like it's using a base-date of 1/1/1970 (actually 12/31/1969) and the number represents the number of days after that.
Most probably this is saved as an offset in days since 01/01/1979:
date('m/d/Y', 15862*3600*24) gives 06/06/2013 and
date('m/d/Y', 15862*3600*24-(3600*24) gives exactly 06/05/2013

SAS Specific Date format

I've found several questions regarding SAS dates in this forum, but i haven't been able to find the answer to this one. I think it is rather simple, but i can't get it right.
I have a data set with a date (DD-MM-YYYY) which for some reason has a Character format. I would like it to be translated into a date format (YYYY-MM-DD). I can get it to 'look' right by by separating and concatenating the parts, but, then i can't get the format right.
Use the input() function with an appropriate informat:
datevariable=input(textvariable,ddmmyy10.);