Openrefine convert number to date - openrefine

I am using Version 3.4.1 [437dc4d] of OpenRefine and a column that keeps numbers like 1986 which is a year. I am trying to convert them to year by clicking Edit cells -> Common transform -> to date , however I get Text transform on 0 cells in column first_appeared: value.toDate() what do I have to do to convert them to date? I see that the error is Error: Unable to parse as date

I used Open Refine 3.4.1 to reconstruct the situation.
That's what I did
Create Project, paste in two year values via clipboard into Open Refine evironment and press Next
Result:
The data from clipboard were classified as line based text automatically.
For this demo usecase it's fine. But datatype can be also different.
Press Create Project
Result:
Prepare edit cells for the column
Result:
Execute edit cells
Result:
Open Refine was executing this function: value.toDate(). It was producing a Date format out of the string - that means: it has transformed the 4 digit origin into a date format.
A valid date object contains more than 4 digits as years - that's the reason why Open Refine did that.

Related

Why is the output for my datediff expression to return a number of days bracketed?

I have written the following expression to give me the number of days between a date and today.
=IIF(Fields!First_Check_Start_Date.Value = nothing,nothing,datediff("d",Today,Fields!First_Check_Start_Date.Value))
The output is correct but is bracketing the number
ie. (292) instead of 292
Any help as to why this is
if you are using text box to display your result, check what is the type of your text box. Make it as number and look for it's format and set to correct
Else you could also format like below
=IIF(Fields!First_Check_Start_Date.Value = nothing,nothing,Format(datediff("d",Today,Fields!First_Check_Start_Date.Value),"##"))
So it appears that whilst viewing in SSRS Report builder the numbers are bracketed (292), however once export to either csv or excel the bracket disappears and is replaced bi a minus -292 which is correct
Thanks

Excel 2016 - Using Get Data to import CSV and format to show in a different column in the worksheet

Currently I have a CSV file that I am trying to import into excel using Get Data, and format to show each value separated in a different column within the excel workbook. I have the CSV with the values separated in the file in such a way as seen below:
VBU|"VBU Name"|"PO Number"|"Customer Order Number"|"Line Number"|"Insert Date/Time"|"Ack Date"|"Confirm Date"|"Company Item Number"|"Vendor Model Number"|"Quantity Ordered"|"Line Status"|"Back Order Reason"|"Cancel Reason"|"Origin State"|"Destination State"|"Tracking Number"|"Expected Delivery Date"|"Expected Ship Date"|"Actual Ship Date"
I am having a hard time separating each value into it's separate column in the excel workbook after importing it using the Get Data - From Text/CSV.
Is there a step I am missing like a custom delimiter for instance, in order to have this imported and formatted in such a way that each column shows the individual value (column 1 = VBU, column 2 = VBU Name, Column 3 = PO Number), etc.? This CSV file, all these values are crammed into the first column when I open the CSV in excel 2016.
Any help would be appreciated.
Nevermind, it was an anomally in one file. Using Get Data -> From File -> From Text/CSV and setting delimiter as | did the trick and I was able to transform it and separate the values into different columns

Changing the title of a column in a PivotTable

I am having trouble changing the title of some columns in a pivot table. I'm trying to make them have dates in them. Each date 6 days further from the last.
Like this
But, I cannot get an equation inside the column title to stay, every time I type in the equation and press enter, it evaluates to either 0 (If the format of the cell is number or general), or 1/0/1990 (If formatted as a date). I checked the value of the cell by =ISTEXT(A1) and it evaluates as true. No matter how I format the cell. So I can never change the title to look like the picture. Any ides?
Here is what I have.
TRUE is the result from ISTEXT()
Even if I manually enter in the formula via the function arguments, it'll show up correct, but when I click ok. It will go back to either 0 or 1/0/1990
Here's the original page
https://drive.google.com/file/d/0B3p8Jm7oNAo4ZUN0Qk1mR1cxYmM/view?usp=sharing
In Excel, dynamic values (formulas) in the header of a table-formatted table are not allowed.
Instead, you can first generate your table header and then format the table as (pivot-)table. You should get a message saying that the header row will be converted in static text (with correct format).

How to use UserForm Values for multiple things

I have UserForm1 which is a multipage userform and I am trying to access the information that was gathered through the form in a sub located in Module1. This sub will need to access several different values and do different things with those values so this is going to be a multipart question.
I have the below code in which I attempt to use one of the values as the upper limit of a For Next Loop. However the current problem is that when the code reaches this line it jumps to the Userform_Initialize routine.
For X = 1 To UserForm1.LocalOffer.Value
Second part of this question comes from inside the For Next loop from above. Where I have the below code. Which would ideally allow me to cycle through a series of similarly named Textboxes from the userform. Not even sure if that will work as the code keeps breaking before getting to that part.
Range("B" & X).Value = UserForm1.Controls("LocalTier" & Tier).Value
Last Part of this question if I have a Textbox in the userform that contains a date in the format 1/18/2015 is there a way for me to grab just a portion of that date say for instance just the Day or just the last digit of the year?
I am using Excel 2013 but the file will be ran on Excel 2007
Edit:
Turns out that problem 1 was fixed by not closing the userform with the X button but instead adding a line to hide the userform when you hit the last button. As it turns out my code for the second question worked just fine once i got past that. Only question left is the last one which I have no ideas on.
As from the comments, I see you don't need anymore to know about points 1 and 2, I will hence limit my answer to the point 3.
Last Part of this question if I have a Textbox in the userform that contains a date in the format 1/18/2015 is there a way for me to grab just a portion of that date say for instance just the Day or just the last digit of the year?
You can use either string manipulation, or date conversion.
Let's assume the Textbox is called myDateTextbox
String manipulation
Among the string manipulators that VBA provides, I would cite Left() and Right().
For example:
last_digit_of_the_year = Right(myDateTextbox.Text, 1)
will return you the last character of the string. On the other hand:
first_digit = Left(myDateTextBox.Text,1)
will return you the first digit of the string.
You can use the Len(myDateTextBox.Text) built-in to return the current length of the string.
Date conversion
You can simply convert your string into date using the CDate() function. Please note this function will return an error if you pass an invalid string. If your textbox contains 24/01/1990, you can first convert the string into a date:
myDate = CDate(myDateTextBox.Text)
Hence, you can retrieve day, month or year like this:
myYear = Year(myDate)
myMonth = Month(myDate)
myDay = Day(myDate)
Please note that CDate recognizes date formats according to the locale setting of your system.. Hence, if the format in the TextBox is not the same than the one of your system, then consider manipulating the string before to adapt it to the proper format. For example, if your system has settings DD/MM/YYYY and your textbox shows a MM/DD/YYYY type, you can "adjust it" as follows:
wrongFormat = myDateTextBox.Text
splittedDate = Split(wrongFormat,"/")
goodFormat = splittedDate(1) & "/" & splittedDate(0) & "/" splittedDate(2)
If wrongFormat was 1/18/2014 but your system would like to read it as 18/1/2014, it's now fine because goodFormat will be equal to 18/1/2014 after the split and re-build.

Excel - Copy the displayed value not the actual value

I am a pilot, and use a logbook program called Logten Pro. I have the ability to take excel spreadsheets saved from my work flight management software, and import them into Logten Pro using the CSV format.
My problem however, is that the work flight management software, exports the date and time of take-off of a flight into one cell in the following excel format: DD/MM/YYYY H:MM:SS PM.
This is handled fine by Excel, and is formatted by default to DD/MM/YY even though the actual value is more specific, comprising of the full length date and time group.
This is a problem because Logten Pro will only auto-import the date if it is in DD/MM/YY format, and there is no way to pull out just the displayed DD/MM/YY date rather than the full date time group actual value, unless you manually go through and delete the extra text from the function box.
My question is: Is there a VBA macro that can automatically copy the actual displayed text, and paste it into another cell, changing the actual value as it does, to just the DD/MM/YY value? Additionally, can this be made to work down a whole column rather than individual cells at a time?
Note I have no VBA experience so the perfect answer would just be a complete VBA string I could copy and paste.
Thank You.
As pointed out in the comments, you'd better not use VBA but formulas instead.
This formula:
TEXT(A1,"dd-mm-yyy")
will return the formated date in a text way. You can drag and drop the formula in the whole range of your cells and Copy/Paste Special > Values so that you will only have the needed values to get imported in Logten Pro.
There are three options using formulas.
Rounddown
Excel stores the date time as a number and uses formatting to display it as a date.
The format is date.time, where the integer is the date and the fraction is the time.
As an example
01/01/2012 10:30:00 PM is stored as 40909.9375
All the values after the decimal place relate to the hours and minutes
So a formula could be used to round the number down to a whole number.
=ROUNDDOWN(A1,0)
Then format the value as a short date.
It will then display as 01/01/2012
INT
As above, but using a different formula to get rid of the fraction (time)
=INT(A1)
Text
Alternately the date only could be extracted as text using this formula
=TEXT(A1,"dd/mm/yyyy")
It will then display as 01/01/2012
I'm a bit late to the party on this one, but recently came across this as was searching for answers to a similar problem.
Here is the answer I finally came up with.
Option Explicit
Sub ValuesToDisplayValues()
Dim ThisRange As Range, ThisCell As Range
Set ThisRange = Selection
For Each ThisCell In ThisRange
ThisCell.Value = WorksheetFunction.Text(ThisCell.Value, ThisCell.NumberFormat)
Next ThisCell
End Sub
This answers the question as asked, apart from the new values are pasted over the existing ones, not into a new cell, as there is no simple way to know where you would want the new values to be pasted. It will work on the whole range of selected cells, so you can do a whole column if needed.