We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

convert a General Date into an ID

Sebastian_c
Sebastian_c asked
on
Medium Priority
297 Views
Last Modified: 2008-03-06
I need to convert a General Date (3/25/2004 3:16:34 PM) into a string or Intiger to be used as
an ID ei: 325200431634

I have tried a couple different things but nothing works....any ideas?
the Date is stored in the field "Date_and_Time_Of_Occurance"
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2006

Commented:
use the format command

sID = Format(myDate,"MMDDYYYYNNMMSS")
CERTIFIED EXPERT
Top Expert 2006

Commented:
sorry, that should be HHNNSS not NNMMSS

Commented:
When just an ID is needed, simply change the date into a number field. :-)

It will have decimals for the hours/minutes/sec part, but an update query with * 100000 can "remove" that when needed.

Nic;o)

Commented:
You can simply manually change the data type of your field to double or single type. The result slightly reminds a date but you'll get an ID field. Also that field easely converts back to Full Date.

Author

Commented:
Thats works great! BUT when I use Date, it gives a number 03262004000000
What happened to the HHMMSS?
BTY You get the points rockiroads!

Author

Commented:
How do I declair General Date in the eqation:

sID = Format(myDate,"MMDDYYYYNNMMSS")
CERTIFIED EXPERT
Top Expert 2006
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Author

Commented:
Thank you rocki!
I ended up using: sID = Format(Time, "MMDDYYYYHHMMSS")
which gives me a unique number each time...

Sebastian
CERTIFIED EXPERT
Top Expert 2006

Commented:
ok, just to note, did you lose the leading zero?
if you did and you dont want to lose it, how about putting YYYY first, just a thought

Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.