Jump to content
Server Maintenance This Week. ×

Help with calculations for barcode data


This topic is 1087 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hi guys!

I am new to the forum and certainly not an expert on FM, I am currently implementing a Code128 barcode for some labels a client of our small business requires us.

Created a field that combines the data I need into one string of data for the barcode generator plugin of FM19 to use.

The issue is with two of those fields

 

First a date field:

I have a production date field  01/05/2021 and I need that data displayed without the separators (01052021)

Second a lot field:

I have a lot field formated M00045 and I need that data without the letters (00045) this I somewhat acomplished with the GetAsNumber calculation but it also removes the zeros that I need to keep as the number grows automatically.

Thanks in advance for your time and help, I really appreciate all input.

 

 

Link to comment
Share on other sites

10 hours ago, JOSUAN said:

I have a production date field  01/05/2021 and I need that data displayed without the separators (01052021)

Keep in mind that Filemaker accepts (and stores) dates with or without leading zeros. If user has entered the date as "1/5/2021" then filtering the field to keep digits only will result in "152021". If you want to be sure that the days and months are padded to 2 digits, use:

SerialIncrement ( "00" ; Day ( YourDatefield ) ) & SerialIncrement ( "00" ; Month ( YourDatefield ) ) & Year ( YourDatefield ) 

or shortly:

SerialIncrement ( "00000000" ; 10^6 * Day ( YourDatefield ) + 10^4 * Month ( YourDatefield ) + Year ( YourDatefield ) )

(I am assuming from your example that the format you want is DDMMYYYY.)

 

  • Thanks 3
Link to comment
Share on other sites

4 hours ago, Ocean West said:





Filter ( table::date ; "0123456789") 

 this will filter out slashes and the same for the LOT if you only want numbers only

 

 

Thanks Ocean for the quick reply, your advice solved my issue of removing the unwanted separators and letters! 😀

 

 

 

4 hours ago, comment said:

Keep in mind that Filemaker accepts (and stores) dates with or without leading zeros. If user has entered the date as "1/5/2021" then filtering the field to keep digits only will result in "152021". If you want to be sure that the days and months are padded to 2 digits, use:






SerialIncrement ( "00" ; Day ( YourDatefield ) ) & SerialIncrement ( "00" ; Month ( YourDatefield ) ) & Year ( YourDatefield ) 

or shortly:






SerialIncrement ( "00000000" ; 10^6 * Day ( YourDatefield ) + 10^4 * Month ( YourDatefield ) + Year ( YourDatefield ) )

(I am assuming from your example that the format you want is DDMMYYYY.)

 

Comment, is there a way to take the date and display it or store it showing DDMMYY?

In my original post I forgot to mention that in my barcode the date needs to show up in 6 digits.

I think FM lets you display 2 digit year dates on layout mode but stores them as 4 digit years for better data accuracy... is there a way to take the stored date and convert it to a 2 digit year via a calculation ? 

Edited by JOSUAN
Link to comment
Share on other sites

8 hours ago, JOSUAN said:

is there a way to take the date and display it or store it showing DDMMYY?

You can use:

SerialIncrement ( "00" ; Day ( YourDatefield ) ) & SerialIncrement ( "00" ; Month ( YourDatefield ) ) & Right ( Year ( YourDatefield ) ; 2 )

Or:

SerialIncrement ( "000000" ; 10^4 * Day ( YourDatefield ) + 10^2 * Month ( YourDatefield ) + Mod ( Year ( YourDatefield ) ; 100 ) )

 

  • Like 1
Link to comment
Share on other sites

On 5/1/2021 at 9:00 PM, comment said:

Welcome to version 7! :tongue3:

What do you reckon is the real difference between the 2 approaches? What makes the one approach better than the other? https://fmhelp.filemaker.com/help/16/fmp/en/index.html#page/FMP_Help/serialincrement.html

 

Did anyone benchmark these two approaches in strace, dtrace or similar and compare the outcome?

Edited by ggt667
Link to comment
Share on other sites

22 hours ago, comment said:

You can use:


SerialIncrement ( "00" ; Day ( YourDatefield ) ) & SerialIncrement ( "00" ; Month ( YourDatefield ) ) & Right ( Year ( YourDatefield ) ; 2 )

Or:


SerialIncrement ( "000000" ; 10^4 * Day ( YourDatefield ) + 10^2 * Month ( YourDatefield ) + Mod ( Year ( YourDatefield ) ; 100 ) )

 

you are my hero, it worked flawlessly, thank you so much!😁

Link to comment
Share on other sites

On 5/2/2021 at 2:04 AM, comment said:

You can use:


SerialIncrement ( "00" ; Day ( YourDatefield ) ) & SerialIncrement ( "00" ; Month ( YourDatefield ) ) & Right ( Year ( YourDatefield ) ; 2 )

Or:


SerialIncrement ( "000000" ; 10^4 * Day ( YourDatefield ) + 10^2 * Month ( YourDatefield ) + Mod ( Year ( YourDatefield ) ; 100 ) )

 

Lastly, I am trying to condtion this calculated fields to generate data only if related to the special client, but I find its only working in some cases.

Example:

Works

If ( c_client = "VIP" ; GetAsNumber ( Lot ) ; "" )

Doesn't work

If ( c_client = "VIP" ; SerialIncrement ( "00" ; Day ( ProductionDate ) ) & SerialIncrement ( "00" ; Month ( ProductionDate ) ) & Right ( Year ( ProductionDate ) ; 2 ) ; " " )

If ( c_client ="VIP" ; Right ( "0000000000" & LotQuantity ; 6 ) & ".00" ; " " )

 

 

 

Link to comment
Share on other sites

Where do you put this calculation? Numeric field with a calculation? Calculation field? Set Field in Script? Others?

Link to comment
Share on other sites

On 5/3/2021 at 3:06 AM, ggt667 said:

Where do you put this calculation? Numeric field with a calculation? Calculation field? Set Field in Script? Others?

text fields with a calculation

Edited by JOSUAN
Link to comment
Share on other sites

On 5/3/2021 at 5:16 AM, comment said:

"Doesn't work" is not a useful description. Can you post a simple file showing the problem - and preferably, nothing else? Something like the attached.

ddmmyy.fmp12 156 kB · 1 download

Ok, by doesn't work I meant that it does not perform the calculation leaving the field with no data or only with the zeros contained in " "

Thank you for the help/patience, I'll try to post the example file.

Link to comment
Share on other sites

54 minutes ago, JOSUAN said:

it does not perform the calculation leaving the field with no data

Your calculation is designed to return an empty result when the test  c_client = "VIP" is false. If you change it to return something recognizable, e.g.:

If ( c_client = "VIP" ; SerialIncrement ( "00" ; Day ( ProductionDate ) ) & SerialIncrement ( "00" ; Month ( ProductionDate ) ) & Right ( Year ( ProductionDate ) ; 2 ) ; "not VIP" )

you will be able to tell if the calculation was indeed not performed or it was performed but the test returned false. 

 

54 minutes ago, JOSUAN said:

or only with the zeros contained in " "

If only zeros are returned, then the ProductionDate field does not contain a date.

 

1 hour ago, JOSUAN said:

text fields with a calculation

Is there a reason you cannot use a calculation field? Do you need the user to be able to override the calculation's result?

 

Edited by comment
Link to comment
Share on other sites

This topic is 1087 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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