Failed to parse input string "" - in BigQuery - parsing

I have a timestamp column in below format
3/31/2020 10:43:17.000 AM
trying to parse it and convert to Date column but running into error
Using below conversion
date(parse_datetime('%m/%d/%Y %H:%M:%E3S %p',datefield))
but running into error
Please note i'm using %E3S at seconds field as per this
https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements
Thanks in Advance

Related

Different date format for same column in Informatica IICS

I am getting data from rest API in JSON forma and have a scenario where a column can have multiple date format. The current date format could be either 2011-02-12T01:00:00 or 2020-04-15T20:44:57.38or could be null or something else also.
I want to parse it through expression and trying to capture the full date string. The following expression seems to be working fine however it is truncating the millisecond part and returning value upto second only.
iif(isnull(%date_fields%),'\N',
to_char(To_date(to_char(%date_fields%),'MM/DD/YYYY HH24:MI:SS'),'YYYY-MM-DD HH24:MI:SS'))
But when I tried it with millisecond usinf below expression:
iif(isnull(%date_fields%),'\N',
to_char(To_date(to_char(%date_fields%),'MM/DD/YYYY HH24:MI:SS.MS'),'YYYY-MM-DD HH24:MI:SS.MS'))
It is throwing error:
TT_11132 Transformation [Expression3] had an error evaluating output column [JobStartDate_out].
Error message is [<<Expression Error>> [TO_DATE]: invalid string for converting to Date
... t:TO_DATE(u:TO_CHAR(t:<02/12/2011 01:00:00>,u:'MM/DD/YYYY HH24:MI:SS'),u:'MM/DD/YYYY HH24:MI:SS.MS')].
I searched few option using below but getting parsing error.
DECODE (TRUE,
iff(isnull(%date_milli%),
'\N',
is_date(To_date(to_char(%date_milli%),'MM/DD/YYYY HH24:MI:SS'),'YYYY-MM-DD HH24:MI:SS'),
is_date(To_date(to_char(%date_milli%),'MM/DD/YYYY HH24:MI:SS.MS'),'YYYY-MM-DD HH24:MI:SS.MS'),
ERROR('NOT A VALID DATE')))
What could be the possible resolution to handle the multiple date format in Informatica? Here JSON date format is string and I am mapping it to date/time type and using Output Marco Fields to combine multiple similar column together.
Why dont you check both options - with and without milliseconds?
You can use below iif condition. Also i think your expression has some issues.
I assumed date_milli is a character type. If its a date, then you can change below expressions accordingly.
iff(isnull(%date_milli%),null,
iif( is_date(to_char(%date_milli%),'MM/DD/YYYY HH24:MI:SS'), to_date(to_char(%date_milli%),'MM/DD/YYYY HH24:MI:SS'),
iif( is_date(to_char(%date_milli%),'MM/DD/YYYY HH24:MI:SS.MS'), to_date(to_char(%date_milli%),'MM/DD/YYYY HH24:MI:SS.MS')
))
)

unable to parse String date "2019-02-23T13:59:13.312401"

I am trying for many hours to parse this date String which is returned by Shodan. "2019-02-23T13:59:13.312401" ISO format is throwing exception.
java.lang.IllegalArgumentException: Invalid format: "2019-02-14T10:16:35.313860" is too short
at org.joda.time.format.DateTimeFormatter.parseDateTime(DateTimeFormatter.java:945)
I am using Joda DateTime library with Google Gson. Anyone knows which format is this and how can I convert it to DateTime object from String.?
Shodan stores the timestamps in ISO 8601 format which you can read more about here:
https://docs.python.org/2/library/datetime.html#datetime.datetime.isoformat
And see here for a previous answer on parsing the format using Joda time:
Converting ISO 8601-compliant String to java.util.Date

Converting DT_WSTR to DT_DATE

So Im pretty new to this stuff but working through a few issues. What I am trying to do is pull source files from a Flat File Source but the dates in all my source files are formatted to YYYYMMDD so I have inserted a Derived Column task and created an expression to format all the columns with dates YYYYMMDD to YYYY-MM-DD and that looks like this:
LEFT(ISSUE_DT,4) + "-" + SUBSTRING(ISSUE_DT,5,2) + "-" + RIGHT(ISSUE_DT,2)
All is good with that except it's in the data type of DT_WSTR so I dropped in a Columns Conversion task to convert DT_WSTR to DT_DATE but I keep getting the following error:
[Columns Conversion [1]] Error: Data conversion failed while converting
column "ISSUE_DT Formatted" (258) to column "Copy of ISSUE_DT Formatted"
(16). The conversion returned status value 2 and status text "The value
could not be converted because of a potential loss of data.".
I have tried opening the advanced editor and navigated to the Data Conversion Output Columns and tried changing the DataType under Data Type Properties to DT_DATE but still the same error..
What am I missing or doing wrong??
Data Flow
Formatted Dates
Column Conversion
Column Conversion Advanced Editor
You have some dates that are not in the format that your SSIS package is expecting. Perhaps single-digit months or days do not have a leading 0. That scenario would definitely cause this specific error.
Take today for example, if single-digit months or days did not have leading zeroes, you have 2018918 instead of 20180918. Without seeing the data, I can't guarantee that this is the exact issue, but it is something like this. The error is occurring when converting the string to the date. So continuing with the example above, after your Derived Column ISSUED_DT formatted would have a value of '2018-91-18' which of course is not a valid date and causes the error.

Need conversion technique from Times ten dateTime to Saxon Timestamp

Trying to retrieve a dateTime Information from Timesten Database and use it in Saxon Xquery .below is the example for that and getting the below error . Do we need to convert timesten dateTime to saxom dataTime if yes how to do that ? pls help me if have idea.
let $DateVar:=fn:data($PERSON/BIRTHDAY)
where as $PERSON/IN_BIRTHDAY is 2010-04-04 03:16:04.000000
if I am trying
let $day-b-DT :=day-from-dateTime($DateVar)
I am getting
Validation error
FORG0001: Invalid dateTime value "2010-04-04 03:16:04.000000" (Day must be two digits)
net.sf.saxon.s9api.SaxonApiUncheckedException: Invalid dateTime value "2010-04-04 03:16:04.000000" (Day must be two digits)
I believe the problem is just your string format, which should be
"2010-04-04T03:16:04.000000". See the documentation for dateTime for more information.
I don't know anything about the Times ten database, or whether you retrieve values in a "rich" format which you happen to be formatting to a string (in which case you should be able to specify a different format) but I believe that's what's wrong.

issue to query data filtered by Date from fusion table

I'm trying to write a small javascript code to query data filtered by date.
If I write the following sentence in my browser, I can get data :
"http://www.google.com/fusiontables/gvizdata?tq=SELECT Date, Poids FROM 3049883"
but if I write the same thing, except I want only data after a certain date :
"http://www.google.com/fusiontables/gvizdata?tq=SELECT Date, Poids FROM 3049883 WHERE Date > 2/29/12"
From the SQL-like API, https://developers.google.com/fusiontables/docs/developers_reference#Select, it should work
I get an error witch is "'internal_error', message:'Could not parse query'"
-Date is a DATETIME format in my fusion table.
-I've tried different format, but I can not get data.
What am I doing wrong?
Thank you very much for your help.
The Date value must be quoted and the format is MM/dd/yy so you must pad single digits with leading zeros.
I had success with:
select Date,Poids from 3049883 where Date >= '02/29/12'
Note: I did not test with gvizdata, just with the FT JSONP API

Resources