Transform the field values pentaho(kattle) and store it in standard format in any table - mysql

I want to transform the value of fields name and Date using pentaho(kattle) and store it in standard format in any table.
For example
id,name,f_n,Date
1,j_vick,03-05-2015
2,jo_vick,04,08,2016
3,Arn_jonnn_vick,05,07,2017
Now I want to transform it using pentaho(kattle) IDE and store it in data base like below:
id,name,Date
1,john_vick,03/05/2015
2,john_vick,04/08/2016
3,Arn_john_vick,05/07/2017
I don't want the transformation steps concern with extraction database storage.

The date format is just some clothing of a value. Just read it with Kettle and store it as is. The database will store it in its proper internal binary format anyway.
Unless, you have to store them explicitly as varchar. In that case, use the Metadata tab of the Select Value step. Define your column as Date and specify the format as dd/MM/yyyy or MM/dd/yyyy. It will be kept internally as a Date, and converted into a String with the selected format at the last moment.
You also seam to have an other problem: the day, month and year are in three columns. The easiest way is to use a Modified Java Script Value step, in which you define a new column date = new Date(year, month, year), with type Date, and let Kettle handle with the format.
Maybe you have mixed input, in which case you can use a Filter or a Swtich step, based on weather you have something in the day and month column.
When that is done, you can make a job that runs the transformation on all the tables. You have an example in the sample/jobs/process all tables furnished with the Pentaho Data Integrator (aka Kettle).

Related

MS Access Calculating date differences if Dates are Short Text

Is is possible in a Table to Calculate differences between Dates if the Value in the field is considered "short text"?
I am working to convert an Excel macro database into Access one and I have imported the data from the Excel file into an Access Table.
however i realized 2 feilds that count up until closure are now just fixed numbers but need to add up as each day passes until closure
when i imported the Dates became Short Text.
is there an expression that would handle this situation?
Each record has a serialized non repeating ID number seperate from access as well.
Dates I have are
OfficialissuanceDate,
DatePlanSubmitted,
DatePlanCompletedSubmitted,
DateClosed,
I need 2 calculations that increments daily when DateplanSubmitted and DatePlanCompletedSubmitted are null
Both comparing to OfficialIssuanceDate. then stop counting when they are no longer null. (have a date in updated to the record) and retain the value.
I have tried to Google calculating Dates but i get DateDiff function which doesnt appear to work. I've used Access and taken a class on it but never really made a new DB from scratch
Dates in a text field are not actual dates, just strings of characters. A Date/Time field stores value as a double number then displays in a date structure - "dd/mm/yyyy" is Access default structure.
Sometimes Access will do implicit conversion of data but not in this case. Either change field type to Date/Time or do conversion with CDate() function. However, you will find that conversion functions error with Null input.
Arithmetic operation with Date/Time field type is possible. However, arithmetic when any term is null returns Null so have to deal with that. One way uses Nz() function: Nz([DateClosed], Date()) - [DateOpened]. Unfortunately, Nz() is not available in table Calculated field type, so do that calc in query or textbox. Most developers avoid table Calculated field type. If you really want to use, expression would have to be: IIf(IsNull([DateClosed), Date(), [DateClosed]) - [DateOpened].

How to retrieve date from database

I have a column in my database that is of type DATE.
I inserted the date via Java using the method: Date.valueOF(LocalDate.now()).
r.setRkd(Date.valueOf(LocalDate.now()));
The entry is correct because the exact date appears in the table.
rkd
------------
2022-03-02
The problem is that when I call the service I don't get the correct date back in the JSON, but a series of numbersenter code here.
"rkd": 1646175600000
Do you know how I can print the correct date in my JSON?
Thank you in advance.
That number you are getting is the milliseconds equivalent to the date you have stored. As far as I know, dates, in general, are stored as milliseconds and displayed in different formats, e.g. YYYY-MM-DD
If you need to display it in date format there should be a method to do it depending on the specific language that you're using.

filtering date column that contains strings as well in MS Access

Good Day,
i have an MS Access DB that has 1 column that contains dates and strings (in different cells). my question is if it is possible to filter by date as date while keeping the strings? the column looks like this:
Date_Col
01/05/15
05/04/18
Not Released
01/01/18
Not Released
this is data from hardware EOL so we need to keep the dates and the strings but we need to have the ability to filter or sort the dates as we wish.
any help would be appreciated as right now when i am trying to filter the column is treating everything as text but if the column was in excel it will filter by date and ignore the strings cells.
You can use a query where you convert that text field to a true date value:
Select *, CDate([Date_Col]) As TrueDate
From YourTable
Where IsDate([Date_Col])
Now, filter on field TrueDate as you like.

Excel import to MySQL: Date inserted as 0000-00-00

I have used PHPExcel library to import an Excel file (.xlsx) and insert into MySQL. I'm facing two problems with the date field:
1- In the excel sheet I try to change the date format to the desired one. Upon saving, the cells show the format I need (yyyy/mm/dd) but when I double-click to edit them they again change back to how it was before (mm/dd/yyyy).
2- When the file is imported to MySQL through PHPExcel all the columns are inserted correctly except the date column which inserts 0000-00-00. The format in the Excelsheet is the same as in MySQL but it enters is all zeros.
Please help!
The value store in PHPExcel is an Excel serialized datetime value (a float, representing the number of days since 1/1/1900 or 1/1/9004 depending on whether Windows or Mac Calendar was used). Changing the format is simply changing the way this value is displayed.
You will either need to know in advance whether a cell contains a date, or test it using the PHPExcel_Shared_Date::isDateTime() method, and convert it appropriately. You can then either retrieve it using getFormattedValue() to return the value as a formatted string; or use the built-in conversion functions to convert it to a unix timestamp (PHPExcel_Shared_Date::ExcelToPHP()) or a PHP DateTime object (PHPExcel_Shared_Date::ExcelToPHPObject()) that you can then format using the standard PHP date formatting functions before using it in your MySQL INSERT/UPDATE statements.
Change the date format to yyyy-mm-dd, save the file as CSV and import that into your database.

Representing Partial Dates in a JSON API

I am managing a RESTful JSON data API, which is growing in scope. Currently, we are returning all dates over the wire as strings "YYYY-MM-DD", but we also need to represent the concept of partial dates.
What I mean by a partial date is a date value that has unknown components, either a Year-Month, or just a Year. In our presentation layer, this would be translated like:
2009-09-03 => '3rd September 2009'
2009-09 => 'September 2009'
2009 => 'Undated 2009'
Is there any precedent or standard for this type of data? For example, MySQL enables this by allowing 00 values in date and datetime fields - eg: '2009-00-00' will save directly to a MySQL date field, but this value does not translate consistently when parsed by most programming languages' date libraries.
What is the best way to semantically represent this concept of partial dates in the JSON feed?
Ideally, we would be able to implement a solution that was easy for our consumers to parse, but also straightforward to explain in documentation.
EDIT: Thinking about this again, YYYY-MM and YYYY are both valid ISO 8601, so it would probably be better to just use that.
There is no standard for JSON dates (of any kind) because JSON is a subset of JavaScript literal syntax, and JS has no date literals. See http://msdn.microsoft.com/en-us/library/bb299886.aspx#intro_to_json_sidebarb .
In terms of storage, you can store the ambiguity by storing year, month, and day in separate columns, and allowing nulls. That way you can query it with string concatenation and the coalesce(day,'00') function to grab out a '00' if a column is blank.
You may find your solution # www.datejs.com
Thanks.