How do I convert a string to timestamp format in Data Refinery from Watson Studio? - watson-studio

I have a csv file that has a timestamp column but it shows up as a String type since I uploaded it locally to the project in Watson Studio. Can Data Refinery convert that string column into actual Timestamp type format?

You can use the Convert Type operation and select the format of timestamp that matches your data. It's not limited to a specific timestamp format...there are different formats you can choose from. For example:

Related

Converting datetime to date in ADF Mapping?

I have a requirement for the final output text delimited document to contain only dates, however the json which I am reading as the Source in my ADF Copy Activity has the datetime fields as "hireDate": "1988-03-28T00:00:00+00:00", for example; I need these to be "1988-03-28". Any suggestions on doing this in the ADF Mapping (and we don't have Data Flow Mapping in the government Azure Cloud).
Thank you
Mike Kiser
No choice, we need an intermediate process, eg: We can copy the json file into a Azure SQL table, then copy from Azure SQL into a txt file.
Create a table and set the column type to date.
create table dbo.data1(
hireDate date
)
Copy into the table. It automatically casts the type from datetime to date .
The debug result is as follows:

BigQuery Timestamp to Ruby time

I have a table with a column timestamp in type TIMESTAMP in BigQuery. When I display it on my console, I can see timestamps as follows: 2015-10-19 21:25:35 UTC
I then query my table using the BigQuery API, and when I display the result of the query, I notice that this timestamp has been converted in some kind of very big integer like 1.445289935E9 in string format.
Any idea on how do I convert it back to normal time? something I can use in my ruby code?
Time.at("1.468768144014E9".to_f)

NSDate being saved as timestamp in CoreData

I currently am saving dates in my iOS application in CoreData. In Core Data, my date attribute is of type "Date". In my NSManagedObjectSubclass file, the attribute is of type: NSDate (which is fine). The date in Core Data is being stored as: 2014/05/16 14:54:51 and when I check the actual values in my SQLite3 navigator, it is being stored in the form:
421959291.293972 for the date
How do I get the above value for the date, and is there a way to convert it back to the form: 2014/05/16 14:54:51? I'm asking this because I am trying to create a dataset via a CSV file, and want to make sure that all the values that I enter in the CSV file are converted correctly by Core Data/SQLite3 into the right format.
if you are using sqlite3 as the command line tool, use the the datetime function to interpret the data, so for example
sqlite3> .schema
create table ZENTITY (... ZSTARTDATE TIMESTAMP, ...)
sqlite3> select datetime(zstartdate,'unixepoch','31 years') from ZENTITIY;
This should give the formatted timestamp stored in the entity table
The unix epoch/31 years arguments come from this stack overflow question.
Behind The Scenes: Core Data dates stored with 31 year offset?

Adding drupal node containing date in drupal-ios-sdk

I am developing an iOS app that needs to create drupal nodes. I am using drupal-ios-sdk to create the nodes. It works fine sending strings to text fields in drupal but the node also needs to contain a date field. When I convert and format the NSDate to a string and put it in a dictionary and send like a text field I get an error from the drupal services module indicating that the date is in the wrong format. What is the correct format or where would I find some documentation?
Here is the best way to find it.
Create a node on your Drupal site first and check the database column for your date field. Then send the date value in the date value in the same format. Also, if you are using date module -- that's obvious, you can convert the string using some date function from the date module.

change date format in sqlite

Change this date format which is in sqlite db 12/10/11 to 12-10-11 (mm-dd-yy) I am unable to do so .I am a noob in sqlite and have to parse this value SELECT strftime('%d-%m-%Y',Date) from report but I am getting null as sqlite db excepts value in mm-dd-yy so How do I convert format 12/10/11 to 12-10-11 (mm-dd-yy) .Thanks in advance .Really appreciate the help.
The short answer:
If you have a text string stored as "12/10/11" that you want reported as "12-10-11", you should use the replace(X,Y,Z) function, to replace occurrences of Y in X with Z. Thus:
SELECT replace('12/24/11','/','-');
will return:
12-10-11
The long answer:
First, dates do not actually exist as a proper datatype in SQLite. They're stored as either TEXT, REAL, or INTEGER values. See date and time datatype in SQLite. So it depends upon how your date was stored in the database.
Second, you seem to be implying that you stored the date in a "mm/dd/yy" format. That's not a valid/useful TEXT format to be storing date/time values (as the date cannot be sorted, cannot used in "greater than" and "less than" operations, cannot be used in SQLite date functions, etc.). You really want to store datetime values in one of the formats listed in the "Time strings" section of the date and time functions document.
So, generally you should store your date/time values in one of those formats, use NSDateFormatter to convert that to a NSDate when you retrieve it from the database. And when you want to display the date value in your app, use whatever format you want for output.
But, if you don't care that the dates are stored as text strings and are not effectively usable as dates in SQLite, then just treat it as a plain old TEXT string and use TEXT functions, such as replace(X,Y,Z) to replace occurrences of "/" with "-", as outlined above.

Resources