Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

importing into a date field

Featured Replies

I have a CSV file that I import into one of my filemaker tables. One of the fields is a date field. All fields except for that one imports fine. What am I missing that is not allowing this one field to come in?

  • Author

date *3/14/2001

If I change the field type in my filemaker table to TEXT it comes in just fine

including the * ;)?

  • Author

I am assuming so. The file was created running a query against a MySQL database using MySQL Query Browser. The results are exported as a CSV. From there I don't see any settings changes that can be made. When I open the file in Excel 2003 and go to format, it shows the first type on the list which is *3/14/2001. Since it is first on the list it could also be that there is actually no formatting what so ever. I am no expert on this.

  • Author

After changing the field to a text field and importing the data it came in with a different format. year/month/day

When I open this CSV file in excel it show as month/day/year.

I can see how this could create a problem. Is there a way I can fix this without having to do it to the file. There are too many records to import them all into one excel spreadsheet.

You are probably going to have to isolate them by patterns, and correct them using scripts. There are some examples of how to use the Substitute Function in both a script, Menu Replace and calculations.

Before we can do much, it would be nice to know what version you are using.

I prefer to do this in a Text Editor, because I can use Grep Patterns to find and replace.

AND, I would diffidently be figuring out a way to uniform this file for future imports.

Lee

I assume that if you open the CSV file with Notepad, Wordpad, or the equivalent on a Mac, you would see the data in year/month/day format. If so, use a text field for importing, then use a calculated date field of

Date( MiddleWords( Substitute( textfield, "/", " " ), 2, 1 ), RightWords( Substitute( textfield, "/", " " ), 1 ), LeftWords( Substitute( textfield, "/", " " ), 1 ) )

Or, if you're using version 7, a date field with an auto-enter calculation of

Let( T = Substitute( textfield, "/", " " );

Date( MiddleWords( T; 2; 1 ); RightWords( T; 1 ); LeftWords( T; 1 ) ) )

For both calculations, I get

This *3/14/2001

That is merely one of Excel's date formats. I believe it is converting 2001/3/14 to it.

Hi JT,

I guess I missed read this, because I thought he said that the date showed as *3/14/2001 in his FileMaker File already.

Lee :woohoo:

  • Author

The *3/14/2001 was one of the excel formats. Not how the dates were showing in filemaker. I will give the calculation a try.

I am using v7.03 developer in conjuction with a Server 7 Advanced.

Thanks for the help.

Edited by Guest

  • Author

I tried it but I must be doing something wrong.

I copied and pasted from your post changing the "textfield" to the name of this field. When I do the import this field comes up blank.

The date format has to be

2001/3/14

For it to work.

Lee

The attached shows how to set up the date field calculation.

pigslow_.zip

  • Author

I downloaded the file and unzipped it but when I try to look at the field or database I get an error message stating that it is unmodifiable.

I take that back...I was opening it before I unzipped it. It looks the same as what I have. Other than some validation that was added by someone else.

Edited by Guest

  • Author

I see a difference in the format that I did not notice.

Instead of having "/" it has "-"

I changed the character in the substitute but I just get a ? in the field after the import.

  • Author

Thanks for all of your help. I was stupid but finally bumped into the problem.

I went to layout mode, date format, numeric seperator. Changed that from "/" to "-" and it comes in just fine.

Thanks again for your attention. I need all the help I can get at times.

  • Author

Ok I take that back. It worked on a small test import of only 5 records.

When I tried to do it for the entire file which was over 80,000 records just that one field did not work again.

Is there a limitation or would it do this if for some reason there is one of the 80k records that is formatted differently?

  • Author

I went through all of the records and noticed there are about 20 records that have no entry in this field.

Would that make this not work as a date field since it will bring them in as a text field?

When you say it didn't work, what did it do? What did it not Do? Are all of the dates the same format as 2001/3/14?

I thought these records already existed?

Lee

:cool:

  • Author

When you say it didn't work, what did it do? What did it not Do? Are all of the dates the same format as 2001/3/14?

I thought these records already existed?

The calculation does work. The import of the 80,000 records does work. What does not work is this date field while bringing in these 80,000 records. I think that is because there are about 20 records that have nothing in this date field.

Would that stop the entire column from coming in?

Would that stop the entire column from coming in?

No. It just would have skipped the date for those records.

Can you attach a sample of the Text File and Your Database?

Lee

:cool:

  • Author

This database is 1.8 GB. It is too big to try and attach. A cloned copy is 4MB.

Even that seems to be a bit large to post here.

Clone "No Records" is 4 mgs?

Then just send a page or two of the Import Text File.

Lee

  • Author

This Sample file is a slice if the records being imported into this Filemaker table.

I find that if I change the field type to text.

Do the import (which does allow the data to fill that column).

Run a script to change the dates from yyyy-mm-dd to mm-dd-yyyy.

Then change the field type back to date.

Everything is fine...until next time I have to do this.

Sample.txt

The dates all show as year-month-day "2004-07-06" which is easier to separate out to be "07/06/2004" than when it is a variable of two and single digits in these fields.

So, if you use this calculation in the Auto Enter Calculation box, it will convert these upon import.

Date(Middle(Date; 6; 2); Right(Date; 2); Left(Date; 4))

HTH

Lee

  • Author

That worked great. Thank you very much for your help.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.