Hello,
perform the following (skip the following 5 steps - if all your dates are already numbers)
- Select the column (click on the column header; e.g. on letter
A
to select column A
)
- Go to
Data -> Text to Column
- Select dropdown Column type
YMD
- Click the square marked red in the screenshot 1) below
- Click
OK
Your dates should get right aligned after the previous 5 steps (or they are already right aligned, if the were numbers before and you skipped the 5 steps above). Now you need to format the cells, to show what you want:
- Select again the column (click on the column header; e.g. on letter
A
to select column A
)
- Go to
Format -> Cells -> Tab: Number
and select Category Date
- Add Format Code
YYYY-MM-DD
(see Screenshot 2)
- Click
OK
Screenshot 1)
Screenshot 2)
Note This answer assumes you want to stay with real dates in your document and does not consider dates to be treated as text. If you want to have text looking like dates, another procedure would be required. But due to the fact, that in almost all cases some calculations using dates are intended, treating dates as text is a bad idea and that’s why this answer focus on real calc dates (which are numbers).
Tested using LibreOffice:
Version: 6.3.4.2,Build ID: 60da17e045e08f1793c57c00ba83cdfce946d0aa
CPU threads: 8; OS: Linux 4.12; UI render: default; VCL: kde5;
Locale: en-US (en_US.UTF-8); UI-Language: en-US,Calc: threaded
Method 2 (Use only if you really want to stick with text)
- Select the column (click on the column header; e.g. on letter
A
to select column A
)
- Go to
Edit -> Find & Replace
and use
Find: ([:digit:]{4}-[:digit:]{2}-[:digit:]{2}).*
Replace: $1
Other Options [x] Current selection only
Other Options [x] Regular expressions
Hope that helps.
If the answer helped you to solve your problem, please click the check mark (
) next to the answer.