+ Reply to Thread
Results 1 to 4 of 4

Recognizing a date format to calculate date in the future

  1. #1
    Registered User
    Join Date
    12-04-2015
    Location
    Wisconsin
    MS-Off Ver
    2013
    Posts
    19

    Recognizing a date format to calculate date in the future

    I have a lot code (plant,date,line,sub) that I need to convert to a date. The lot code is always a 10 digit number.
    6051230220… The date is located in the 3rd – 7th digit, represented as YMMDD. So in this case it is 51230 or December 30, 2015. I am ultimately trying to get the expiration date which will be random but for this argument it will be 60 days. I am using a user form (UserForm1). The user enters the lot code into (LotTextBox1). I have an expiration date box on the user form (ExpDateTextBox1). I decided to use the worksheet in the workbook (User Form) to get the date value separated using the mid function. I figured I could have the user enter the lot code in the User Form worksheet and manually type it in the (ExpDateTextBox1) on the userform (UserForm1). But I can’t get the format to be recognized as a date to add the days to get the expiration date. Any ideas?

    If there is a way to calculate it right on the userform and not use the mid function that would be great too but I will take either way.

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,724

    Re: Recognizing a date format to calculate date in the future

    How do you know that the 5 relates to 2015 and not 2005?

    Anyway, if that code was in A1, then you could do this to get the date:

    =DATE(2010+MID(A1,3,1),MID(A1,4,2),MID(A1,6,2))

    and you can add 60 on to that to get the expiration date.

    Hope this helps.

    Pete

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Recognizing a date format to calculate date in the future

    Hello Nole68,

    If you post a copy of the workbook it will make it easier to help you solve this problem.

    If your workbook contains any information you do not want made public, please redact it before posting the workbook.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  4. #4
    Registered User
    Join Date
    12-04-2015
    Location
    Wisconsin
    MS-Off Ver
    2013
    Posts
    19

    Re: Recognizing a date format to calculate date in the future

    Thanks Pete. I am in the food industry so things don't last that long, so having a single digit year is ok. Everything we do has to fit on a UPC symbol and with all the requirements there is limited space in the UPC, any reduction we can get helps. I used your formula and it worked great, at least through 2019. ;-)

    Thanks Leith, I am going to roll with Pete's solution.

    Thanks!

+ 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. Calculate Date 5 years in the future past today's date
    By RickCJ7 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 05-29-2015, 05:50 PM
  2. Replies: 6
    Last Post: 08-10-2006, 11:30 PM
  3. [SOLVED] formula to calculate future date from date in cell plus days
    By Chicesq in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 11-03-2005, 08:30 AM
  4. calculate future date
    By Ron Rosenfeld in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 09-06-2005, 12:05 PM
  5. calculate future date
    By kevrgallagher in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 03:05 AM
  6. [SOLVED] calculate future date
    By kevrgallagher in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 11:05 PM
  7. [SOLVED] calculate future date
    By kevrgallagher in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-08-2005, 10:05 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