Reading dates with JuliaDB - julia

I am very new to Julia, and I am having an issue with JuliaDB loadtable("myfile").If I understand well, the problem is that the dates are in the format dd/mm/yyyy, e.g. 21/07/1985. I am told 'ArgumentError:Month: 14 out of range (1:12). How can I tell Julia the format of the date of the file I am reading?

As answered here, you can use the argument colparsers to solve your issue:
loadtable(path, colparsers=Dict(:datecol => dateformat"MM/DD/YYYY"))

Related

How to convert Unix Time to Human Readable in Integromat?

My preceding module in Integromat gives me an expiration date in UNIX time, which is 1640930400.
When I use the FormatDate function to convert this, I'm getting 12/31/1969 when I was expecting to get 12/31/2021. I can't seem to figure out what I'm doing wrong here. Any help would be much appreciated.
Use this instead to first parse the date and then apply the desired formatting to get the results that you want,
{{formatDate(parseDate(1.date; "X"); "MM/DD/YYYY")}}

Apache Nifi Expression Language - toDate formatting

I am trying to format a date string using the Apache Nifi expression language and the Replace Text processor(regex). Given a date string
date_str : "2018-12-05T11:44:39.717+01:00",
I wish to convert this to:
correct_mod_date_str: "2018-12-05 10:44:39.717",
(notice how the date is converted to UTC, and character 'T' replaced by a space.)
To do this, I am currently using:
toDate("yyyy-MM-dd'T'HH:mm:ss.SSSSSSXXX"):format("yyyy-MM-dd HH:mm:ss.SSS", '+00:00')
and this works perfectly.
However, when the date string has 6 digits in ms, rather than 3, things break:
another_date_str: "2018-12-05T11:44:39.717456+01:00"
is converted to:
incorrect_mod_date_str: "2018-12-05 10:56:36.456"
It seems the first 3 digits in the ms precision interferes with the conversion.
Appreciate inputs to resolve this - what am I missing?
Regards
seems that's a limitation in java.
according to java documentation there is no support of more then 3 milliseconds digits.
https://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html
the simplest way is to remove extra digits like this:
attr:replaceAll('(\.\d{3})\d*','$1'):toDate("yyyy-MM-dd'T'HH:mm:ss.SSSXXX"):format("yyyy-MM-dd HH:mm:ss.SSS", '+00:00')
I ran into a similar issue with date time encoded in ISO 8601. The problem is, that the digits after the second are defined as fragment of a second, not milliseconds.
See answer to related topic

Where do I find the reference for TO_DATE format string

I need to convert a string formatted as MM/DD/YYYY HH:MI plus AM/PM, but can't find a complete reference to the format string to find how to specify the AM/PM part.
I would certainly appreciate information on how to do this, but would appreciate a link to a good source of documentation for this even more.
:EDIT
SELECT top 1
v.CalendarDateTime
,TO_TIMESTAMP(v.CalendarDateTime,'MM/DD/YYYY HH:MIAM') as CalendarDateTimeTS
--,CAST(TO_TIMESTAMP(v.CalendarDateTime,'MM/DD/YYYY HH:MIAM') AS TIMESTAMP(0) FORMAT 'MM/DD/YYYYBHH:MIBT') AS CalendarDateTimeTS2
12/03/2015 03:00AM 12/3/2015 03:00:00.000000
The commented out line produces a "DateTime field overflow" error.
You probably want TO_TIMESTAMP instead of TO_DATE.
The only bad thing about the Oracle function is the resulting datatype of TIMESTAMP(6) which can't be changed:
TO_TIMESTAMP('12/03/2015 03:00AM', 'MM/DD/YYYY HH:MIAM')
Using Teradata's FORMAT you can specify the timestamp precision, but it's less flexible than Oracle's, the string must match the format exactly:
CAST('12/03/2015 03:00AM' AS TIMESTAMP(0) FORMAT 'MM/DD/YYYYbHH:MIT')
On the Teradata site you'll find the (slow) online docu, e.g. TO_DATE formats or Teradata FORMATs. Of course you should download the full documentation CD for your release.
Please tell us at least which programming language are you using.
Normally it would be something like "MM/DD/YYYY HH:MI a" but we need to know first you language.

Date Format for Mathematica

As I am trying to plot a few financial time series in Mathematica, I just ran into a problem illustrated in the figure below :
It seems the data are no longer dealt with after Year 2000
Is there a way to fix that ?
What would be the best format to export time series from Bloomberg or Excel to use them in Mathematic (Using version 8).
I do know about the FinancialData function. However, not knowing the exact symbols, it makes it extremely difficult to use Mathematica directly for this.
Why not to use WolframAlpha[...] function - it imports native to Mathematica format and goes up to current dates:
timeseries = WolframAlpha["msft close Jan 1, 2010 to Jan 21 2011",
{{"DateRangeSpecified:Close:FinancialData", 1}, "TimeSeriesData"}];
DateListPlot[timeseries]
That was just an example of input. I am not sure what kind of data you need exactly, but you can get a lot of them via WolframAlpha function. Read this:
1) WolframAlpha
2) Data Formats in Wolfram|Alpha
Use the DateFunction option to tell DateListPlot how to convert dates:
DateFunction -> (DateList[{#, {"MonthNameShort", "YearShort"}}] &)
(The parentheses are important.)
Here's a function to convert those date strings to a format Mathematica can handle better:
dateConv = With[{s = StringSplit[#, "-"]}, {DateList[{s[[2]], "YearShort"}][[1]],
DateList[s[[1]]][[2]]}] &
You can try
DateListPlot[data, DateFunction -> dateConv]
EDIT: Originally I tried DateList[{"Nov-11", {"MonthNameShort", "YearShort"}}] but this tells me String "Nov-
11" cannot be interpreted as a date in format {"MonthNameShort",
"YearShort"}.. Perhaps a bug?

Package to parse dates in Common Lisp?

I'm writing a simple web scraper in Common Lisp (SBCL) as a learning exercise, & would like to sort by date. To do this, I'll need to parse dates in the format "MM/DD/YYYY" into universal time.
I could simply tokenise the string & pass the bits into encode-universal-time, but I figure that there must be a built-in function (or popular third-party package) for date parsing. I'd greatly appreciate someone recommending one :-)
This answer is very late but the local-time library is featureful and widely used. It is based on the article The long painful history of time.
It supports :
Time and date arithmetic
ISO 8601 timestring formatted output and parsing
Reader macros to embed timestrings directly in code
Timezone handling (will read unix tzfile format)
Conversion between universal and unix time epochs
Julian date calculation
See the net-telent-date and simple-date-time libraries for Common Lisp. The former has a parse-time function you can use (see parse-time.lisp). Both are included in the QuickLisp library collection.
You could try net-telent-date, which has PARSE-TIME which I think will do what you want.
It's now 2022, and net-telent-date is on github and is also deprecated. Better to find something else.
Many implementations have a UNIX interface and, in same cases, this includes the strptime function.
Antik handles dates and times and includes date/time parsers. The result is a "timepoint" which by default is UTC (CL's "universal-time" is something different, but it can be converted to that).
I use local-time and cl-date-time-parser:
edit: and chronicity for parsing natural language dates and times.
(local-time:parse-timestring "2019-11-13T18:09:06.313650+01:00") ;; OK
(local-time:parse-timestring "2019-11-13") ;;OK
This fails with local-time by default:
(local-time:parse-timestring "2019/11/13")
but it works with Chronicity:
(chronicity:parse "2019/11/13")
#2019-11-13T00:00:00.000000+01:00
and we can set the date separator of local-time to "/":
(local-time:parse-timestring "2019/11/13" :date-separator #\/) ;; OK
There is also the time and datetime separators.
Now a format like ""Wed Nov 13 18:13:15 2019" will fail. We'll use the
cl-date-time-parser library:
(cl-date-time-parser:parse-date-time "Wed Nov 13 18:13:15 2019")
;; 3782657595
;; 0
It returns the universal time which, in turn, we can ingest with the
local-time library:
(local-time:universal-to-timestamp *)
;; #2019-11-13T19:13:15.000000+01:00

Resources