LibreOffice: Cells with text to date - date

I have loaded an xlsx file where the original author used Microsoft Office to create the file. In the spreadsheet, there is a column of dates given in format like "DD/MM/YYYY TT:MM:SS", but they are stored as text. Furhteron, "DD/MM/YYYY TT:MM:SS" is not locale default. I cannot find a way to make LibreOffice interpret it as date. Can someone please help me to reach my aim?

Highlight the column of dates. From the menu, select Data -> Text to columns. In the dialog window that pops up, press "OK". That should do it.

Related

Date formatting in Google Sheets is not working according to the instructions

Yes, I know; this question has been asked thousands of times in hundreds of different places, but Google Sheets stubbornly refuses to let me convert a date such as "9/18/2004" to "2004-9-18". I select one or more cells whose date format is "dd/mm/yyyy", click on FORMAT, then NUMBER, then MORE FORMATS, then I select "More date and time formats", and then select the example "1930-08-05", and then nothing happens. Nothing changes. I need help with this. Here is a link to the problem column:
https://docs.google.com/spreadsheets/d/1gYdPcNO-Jq1SFUpdb88o7KKVqG5_ia9NpD_3T98CkEw/edit?usp=sharing
Thanks.
From Google:
Change locale and time zone
When you change the locale and time zone of a spreadsheet, it changes the spreadsheet’s default currency, date, and number formatting.
On your computer, open a spreadsheet in Google Sheets.
Click File and then Spreadsheet settings.
Under "General," click the "Locale" and "Time zone" menus to change your settings.
Click Save settings.
Changing the locale doesn’t change your language settings in Google Sheets. You can set the language in Google Account settings.
Worked for me :)
9/18/2004 is not a date. its text string. if you change it to 18/9/2004 then you have a valid date and you can apply your desired formatting
to quickly reformat it you may use:
=ARRAYFORMULA(TEXT(IF(ISNUMBER(A2:A*1), A2:A, DATE(
REGEXEXTRACT(A2:A, ".{4}$"),
REGEXEXTRACT(A2:A, "^\d+"),
REGEXEXTRACT(A2:A, "/(\d+)/"))), "yyyy-mm-dd"))
So this just worked for me:
Change settings as advised - but THEN:
Insert a new column
Copy all dates from the original column into the new on with "paste special" => "values only".
Then select all dates and format again as date. From there on I could sort according to date etc.

How do I change the date format from MM/DD/YYYY to DD/MM/YYYY in libreoffice calc?

I have a spreadsheet with existing date values that I'd like to convert from MM/DD/YYYY to DD/MM/YYYY format. Is there any way of doing this?
The spreadsheet comes from a csv file from someone else that i have opened in calc.
Select the cells with the dates and in Cell -> Format, choose the date format you wish (DD/MM/YYYY)
Making sure the cells are selected, go to Data -> Text to columns choose "Separated by" and "Tab" and click "OK"
Cells should now have the desired format
Cut (or copy then erase) all values from the column (CTRL + X).
Choose Edit -> Paste Special -> Unformatted text (MAJ + CTRL + ALT + V).
On "Fields", click on your column, then select "Date (MDY)". It is important here to select the format the data currently is, NOT the format you want it to be.
If date is still not OK, you will need to follow this additional step (response above from #cybernetic.nomad):
Select the cells with the dates and in Cell -> Format, choose the date format you wish (DD/MM/YYYY).
NB: Note that my LibreOffice Calc is not in english so I am not 100% sure about the option names.
You select the cells to format, then you press Ctrl-1 (or choose "Format" - "Cells..." from the menu, or any other way) to open the dialog to format cells. There is a text field "Format code" where you enter "DD/MM/YYYY" without the quotation marks. Click "OK".
If that does not format the date like you want, the value in the cell is not interpretable as a date. Investigate the cell's value, you might have a text marker (a single apostrophe ') as the first character.
To check this out and experiment with the formats, choose "Insert" - "Date" from the menu. It puts the current date into the current cell.
Disclaimer: Since my Calc is not set to English, the names of menus and their entries might be different. I just guessed how they could be named.
EDIT:
If you can't change the cell format because the date is constantly recognized as "text", you might like to try this:
Insert a column right from the date column. This produces in your case the column O. All columns right of it are pushed to the right.
Put this formula in cell O2 on the right of the first date text:
=CONCATENATE(MID(N2;4;3);MID(N2;1;3);MID(N2;7;4))
It takes snippets (MID()) from cell N2 and concatenates them in the new order. Details of the functions are in Calc's documentation.
You will need to adjust N2 to the correct cell reference if it is not the cell directly left of the cell you're entering the formula.
Put the cell cursor on N2.
Press these key combinations in sequence to mark a deep enough range of cells in column O: Control-Down, Right, Shift-Control-Up. The cell cursor will be on cell O2 now, and the range below and including it is marked.
Now press Control-D to copy the formula in O2 into each cell in the range.
Now you will have a new column O with the text of N, but exchanged characters. The values are still "text", though.
If you like, you can shrink the width of column N now, or hide it.
Example:
Input wanted: DD/MM/YYYY (31/12/2021)
Input accepted: MM/DD/YYYY (12/31/2021)
First add new Date type
Go to Format --> Cells
In "Category" select "Date"
In "Format code" write the input wanted. In this case DD/MM/YYYY
Press the green check
Second format style
Go in the cell where you want to add the date
Write the date in the wrong format. Example: 12/31/2021 (for 31st December 2021) even if you want 21/11/2021
Select that cell and press CTRL-X. The text should disappear
Select that now empty cell and do: Edit -> Paste Special -> Pase unformatted text
The date should be there in the wrong format
Select that cell with the wrong date and do: Format --> Cells
In "category" select "date" and double click on the newly added date type (aka DD/MM/YYYY)

Automatically convert date text to correct date format using Google Sheets

I'm trying to convert date from "text" to correct format. It is logged to Google Spreadsheets and I'm unable to use it to plot graphs.
This is the text format: February 3, 2018, at 11:21 AM
Time is not relevant, all I need is the date converted: DD/MM/YYYY.
I found a similar question where Gary's Student answered with a formula that looks like this for a different format:
=DATEVALUE(SUBSTITUTE(A1,MID(A1,FIND(" ",A1)-2,2),""))
(link to that question)
How can I use above formula (or something similar) so that text is converted to date?
Thanks in advance.
The , at portion of the string is keeping Google Sheets from recognizing it as a datevalue. Just remove it with the substitute function and wrap in datevalue function like so: =DATEVALUE(SUBSTITUTE(A1,", at",""))
To format as DD/MM/YYYY just go to custom formatting and set it to look like the following:
=DATEVALUE(JOIN("/", LEFT(D5,2), {MID(D5,4,2), RIGHT(D5,4)}))
where D5 contains for example: 25.06.2019
which script converts to datevalue: 43641
Dateformat is as dd.MM.YYYY converted to dd/MM/YYYY and then converted to datevalue.
Google sheet's documentation helps:
DATEVALUE, JOIN, LEFT, MID, RIGHT
Datevalue is useful for organizing rows of data by date correctly.
Another solution is to create custom function.
Open tools → script editor in menu to open script editor in new tab
Click Untitled project in top left corner and rename
Open Resources → Libraries in top menu
Paste library key MHMchiX6c1bwSqGM1PZiW_PxhMjh3Sh48 and click Add to add the Moment library to your script
Choose Moment version 9 and click Save
Paste function
function parseDate(dateString, format){
return Moment.moment(dateString, format).toDate()
}
to Code.gs and save project Ctrl+S
Now you use your function in any cell in your sheet:
=parseDate(B2,"MMM D, YYYY, at HH:mm A")
more details about format:
https://momentjs.com/docs/#/parsing/string-formats/
You can also create function to display date in custom format:
function formatDate(date, format){
return Moment.moment(date).format(format)
}
Use it like this in cell
=formatDate(B5,"DD/MM/YYYY")
or
=formatDate(parseDate(B2,"MMM D, YYYY, at HH:mm A"),"DD/MM/YYYY")

Crystal Reports Parameter Input dialog box changing the date format

When I generate a report that expects two date parameters, I first see the dialog box titled 'Enter Values' and the dialog box contains two text boxes with its own date picker widget. However, once I pick a date and click 'OK', the date is formatted as 'dd/MM/yyyy'. Does anyone know if it is possible to configure the report in a way so that the date format matches Windows system locale short date format? Instead of just defaulting to dd/MM/yyyy?
Thanks!
The date format for the parameter can't be changed, at least as far as I know. If you want the date displayed in a different format, you can always create a formula:
"From : " & ToText(Minimum({?date}), "M-d-yy") &
" To :" & ToText(Maximum({?date}), "M-d-yy")
Or you can go into the File menu, click on Options and under the Fields tab, there is a button for Date. Click on that and you can choose the format under the Date tab. This is for CR 2008, so it may be slightly different for CR XI.
If You are trying to filter in your SQL on date range field then you can add castings on dates. Like
datarangeField between cast({?Start Date} as date format 'm-d-yy')
AND cast({?End Date} as date format 'm-d-yy')
Also, you are required to add these (Start Date and End Date) in your SQL Parameters during Adding the query.
For display you can use formulas and format field options.

Add date to to Crystal Report Text Object

I have a Text Object on my report which is contains some text. What I'd like to do is add a date to the text object that will alaways show the current date. I've tried using a date field, but it is near impossible to line it up correctly.
Any ideas on how to do this? I've been told that there is a way to do this using something like &[], but I can't figure out how.
Thanks!
You can edit the date inline, double click on the text field then select the date text, you can now click on the formatting button on the toolbar and setup the date format.
You can drag any field, including special ones (Print Date for example) into text object - it will line up without problems.