I found this quite tricky, not because it’s tricky in principle but because there are a number of things that we can overlook if we are in a hurry. I will explain what can go wrong both in terms of what to do, and then in terms of why it can look right in Calc but not import into Base properly. I thought I would document how I get it to work reliably, both for my convenience next year, and for anyone else who only does this occasionally and gets as stuck as I did today.
- Get your data into a .csv file from whatever source.
- Open this file in Calc. IMPORTant (pun intended) any columns containing dates must be loaded as Date columns, not as Standard – these are the headers. This will give you the choice between DMY, MDY, or YMD formats
- Check that the data is lin3d up properly, if not tweak it, save as .csv, reload (with Barclays bank file I seem always to have to adjust the first two rows) and start again from top
- Select all the data you want
- Go over to Base
- Go to the Tables screen (click on the tables icon, or View → Tables and put the mouse pinter in the bottom half
- Edit → Paste or right-click ->paste
- Change the table name if it has suggested an existing one to a suitable temporary table name (I will use T)
- Choose definition and Data
- Remember to change the format of the date column, and any numeric columns - Base will not pick up what you did in Calc
- Look at T in edit mode: are you happy with the data types
- Look at T: did the dates and any numbers come across?
13.Use Tools → SQL to execute INSERT INTO ( … ) SELECT … FROM T to move the data into whjrever you really wanted it
OK that’s my recipe. If your brain works like mine, know how and why it can go wrong helps to get it right, so I will explain that below. Stop reading here if your brain is not wired like mine
Why it can go wrong is that while dates look like dates in Calc, really they are numbers. Christmas day 2022 is really 44920 for example. Midday on that day is 44920.5
It looks like text, whether you loaded it as a date or as Standard. Sadly, if you loaded it into Calc as Standard, it really is text, and when you try to load it into a field you said was a Date, you get that annoying Java error saying the data type is wrong, and all your dates are NULLed out (or no rows are transferred if you made the date an essential value).
Conversely, if you loaded the .csv file correctly into Calc, but then forgot to tell Base you wanted it as a date, you will get a five digit number (integer for a date, or a timestamp at midnight; fraction for timestamps at other times).
If you get it wrong, delete the temporary table and start again: trying to fix it after its gone pear shaped takes far longer, at least in my experience. For one thing, different versions of the back end HSQLDB database either do or don’t accept the functions to convert from text to date.
I hope this is helpful. I am new here, (or rather newly returned after a 4 year absence) so if this should have been posted somewhere else please could a suitable wizard move it for me and tell me where it really belongs so I will know next time I want to post a tip rather than a cry for help.
Merry Christmas to anyone else who’s online as I type: HO! HO! and indeed HO!