How to use system time to generate unique id?

M

Marina

I would additionally like to point out, that if using letters and numbers,
we are talking 36^16 different possibilities for a GUID, if using the first
half of a GUID (without delimiters). I don't know about you, but that is
enough for me.
 
J

Jay B. Harlow [MVP - Outlook]

Marina,
I'm sorry, I'm concerned you are missing my point.

1) that a System.Guid is more assured of being unique then a subset of it.
2) that taking a subset of it doesn't appear to buy you anything (in terms
of uniqueness or memory).

Ergo using a System.Guid itself appears to be better then using a subset!

As I stated: I will stay with Guid itself, rather then a fragile design. If
you or others favor fragile designs, hopefully I do not inherit them.

Enough of this, I can tell I am really not going to convince you, and you
are not going to convince me. Thanks for the interesting discussion...

Later
Jay
 
C

Cor Ligthert

Marina,

Jay is from the US (maybe as you), he thinks probably that larger numbers
gives more security.

When I buy a lottery ticket here in this small country, I have probably as
much change to win as there in the US.

(In fact Jay is right of course, the larger the number the less change there
is on duplicates, however complete sure you are never how long the number
will be)

I hope that I clear with this, that we agree as almost forever again, (and
not disagree with Jay before he thinks that)?

:)

Cor
 
J

JohnBoy

Geez, chill out!

Jay B. Harlow said:
John,
KA BOOM!!!! Your sample just gave me hundreds of duplicate entries!

At the very least you may want to include ALL 7 digits for milliseconds!
Plus full width (both digits) for months, days, hours, minutes & seconds!


As your string will give duplicates on for Jan 11th & Nov 1st, plus it
will give duplicates between for 11:01 & 1:11!

To see what I mean try the following:

Dim dt1 As DateTime = #1/11/2005 11:01:00 AM#
Dim dt2 As DateTime = #11/1/2005 1:11:00 AM#
Dim str1 As String = dt1.ToString("MdyyHmsfff")
Dim str2 As String = dt2.ToString("MdyyHmsfff")

Debug.WriteLine(str1, dt1.ToString())
Debug.WriteLine(str2, dt2.ToString())

Debug.WriteLine(str1 = str2)


Of course when the clock falls back for daylight savings time, there will
be an hour where duplicates are also created! Also if you explicitly
adjust your clock or Windows adjusts your clock, you will have another
opportunity for duplicates.

My money is on using the full "precision" of System.Guid.

Hope this helps
Jay
 
J

Jay B. Harlow [MVP - Outlook]

John,
Odd, I thought I was "chill" and had attempted to explain rather nicely &
politely why your routine would very quickly give duplicates.

Just a thought
Jay
 
J

JohnBoy

Anal Jay,

Keeps your "thoughts" to yourself.


Jay B. Harlow said:
John,
Odd, I thought I was "chill" and had attempted to explain rather nicely &
politely why your routine would very quickly give duplicates.

Just a thought
Jay
 
J

Jay B. Harlow [MVP - Outlook]

JohnBoy,
Such professionalism!

Seeing as I live in a free country that prides itself on freedom of speech.
I will not even presume to suggest that any one should keep their thoughts
to themselves! In other words you are totally within your rights to think of
me as you will, and to state that opinion here. Others reading your
assessment are equally free to agree or disagree with your opinion.

Me personally, your personal comments about me are immaterial! I will
continue providing the highest level of support that I am able to!

Have a nice day.
Jay
 
C

Cor Ligthert

Jay,

In my opinion it was a very correct answer you did, when I had seen it
directly I had probebly done it as well.

You know my standard answer on this, when people start throwing mud in a
discussion, they lost it and show only something about themselves.

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top