Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date time imbedded in a formula that can be barcoded

Status
Not open for further replies.

GCL2007

IS-IT--Management
Dec 11, 2007
167
US
I'm trying to create a formula that will extract first 6 digits of part number that and also the current datetime stamp. Thinking of something like this in a formula
left(partnumber,6)+'-'+totext((CurrentDatetime)).

This will leave me a value like 55555-1/21/2011 00:00:00
which is fibe but it's going to leave me a barcode with breaks where there is a space.. not sure how it's going to treat the : and other seperators. Is there a better way to do this?
 
Do you know what the end result of the formula should be? You can replace the spaces by using:

left(partnumber,6)+'-'+replace(totext(CurrentDatetime)," ","")

-LB


 
Thanks LB - I think that will work. I was digging into it and thinking of using something like this - but will also play around with your suggestion.. Thanks!!!!


Left({partnumber},6)+'-'+Cstr(CurrentDateTime,"yyyyMMdd-HHmmss")
 
As a follow-up I now have the CurrentDateTime correctly printing on my document in the format YYYYMMDD-HHMMSS.
That works great - I am going to barcode this and the users are going to scan that in to a text field in my database.
I now want to report that text field (with my date code) and compare it against actual date fields in the database. How would I convert it back to a date field in a report. It is just in a text field now with the format YYYYMMDD-HHMMSS.
Thanks!
 
There may be a simpler way, but i think this will work as long as you always have YYYYMMDD-hhMMss as your data format.

stringvar ddt := {YourTable.YourField};
numbervar yr := tonumber(LEFT(ddt,4));
numbervar mo := tonumber(MID(ddt,5,2));
numbervar da := tonumber(MID(ddt,7,2));
numbervar hr := tonumber(MID(ddt,10,2));
numbervar mi := tonumber(MID(ddt,12,2));
numbervar se := tonumber(RIGHT(ddt,2));


datetime(yr,mo,da,hr,mi,se)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top