+ Reply to Thread
Results 1 to 9 of 9

LibreOffice: Turn batch number into date

  1. #1
    Registered User
    Join Date
    08-05-2019
    Location
    Missouri
    MS-Off Ver
    LibreOffice Calc
    Posts
    3

    LibreOffice: Turn batch number into date

    Here is an example of the batch numbers at my company: 1599. 159 being the day of the YEAR. Day 159 being June 8th (formula needs to account for leap years). The final digit indicates the most recent year ending in that number (9 being 2019). Looking to change the batch number to a (mm/did/yy) format.

    Would also like to know how to take that formula and add specific amounts of time for given expirations of products. 18 month expiration and 3 year expiration to be used so I can figure out how to manipulate the formula.

    There was a time in college when I could figure this out but I just cannot wrap my head around this problem. Please help me out.

    Thank you!

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Turn batch number into date

    I currently do not have access to excel (at work), so untested, but Im thinking of something like (assuming that is in A1)...
    =date(year(today),1,1)+left(a1,3)
    Not really sure how the last "9" is relevant here though? What would it be next year?

    add specific amounts of time for given expirations of products.
    I assume that meant add days, not time?

    If so, (again, untested)…
    =edate(date,18) will give you 18 months from now. Use 36 for 3 years.

    Try that and let me know how you make out?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,879

    Re: Turn batch number into date

    I think Ford missed a few Parens. Also, need to add 159 to Jan 1, 2019. This should work. Good analysis of the situation, Ford.

    =DATE(YEAR(TODAY()),1,1)+LEFT(A1,3)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  4. #4
    Registered User
    Join Date
    08-05-2019
    Location
    Missouri
    MS-Off Ver
    LibreOffice Calc
    Posts
    3
    So if the product was made July 8th, 2020 the batch number would be 1590. Our products expire so it is important to know when it was manufactured so we can sell them before expiration.

    So far I have gotten the #NAME?

    Which part of the equation accounts for the year?

  5. #5
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Turn batch number into date

    Alan, thanks for picking that up

    Brett, the YEAR(TODAY()) ID's the year

    The formula says...

    give me the DATE where the YEAR = TODAY's year, with the month = 1 and the day = 1. Then take the left-most 3 digits from that value in A1, and add it to that date.

  6. #6
    Registered User
    Join Date
    08-05-2019
    Location
    Missouri
    MS-Off Ver
    LibreOffice Calc
    Posts
    3

    Re: Turn batch number into date

    Okay I am getting somewhere.

    Referring to A1 as 1599 I used this formula:
    =DATE(Year(today()),1,1)+left(a1,3)-1
    The “-1” on the end makes up for starting on the 1st of January, 1 day into the year. However, the year will not always be consistent with Today’s year. We have products that were produced in years prior. Maybe an IF function will help? This will be tricky because the final digit referred to the most recent year ending in that number.

  7. #7
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Turn batch number into date

    OK so how would we know that the date in the "1599" was from last year? Would it be 1598?

  8. #8
    Valued Forum Contributor Root_'s Avatar
    Join Date
    07-29-2017
    Location
    _
    MS-Off Ver
    2010+
    Posts
    484

    Re: Turn batch number into date

    @ brett17

    Is this what you need?

    =DATE(LEFT(YEAR(TODAY()),3)&RIGHT(A1),1,LEFT(A1,3))

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: LibreOffice: Turn batch number into date

    The OP has LibreOffice, so the thread has been moved to the other platforms section.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How to create a date of manufacture and expiry date from a batch number
    By misterzim in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 10-23-2018, 05:24 AM
  2. Replies: 4
    Last Post: 06-07-2017, 10:44 AM
  3. [SOLVED] Turn a number into a date
    By sungen99 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-02-2017, 01:07 PM
  4. [SOLVED] Add 12 weeks to date to return week number turn over at 52 weeks
    By nigelog in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-01-2017, 05:58 AM
  5. Libreoffice: Use data in Base for calculations in Calc. Possible?
    By vivace in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 05-14-2013, 08:04 AM
  6. Replies: 1
    Last Post: 10-02-2012, 02:42 PM
  7. Replies: 1
    Last Post: 07-30-2010, 03:35 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1