Dec 3, 2010 8:30 pm
Ratullloch_delthisGreetings All
I would like to use the current date and time as a serial number in csharp what command or tutorial if there is one should I use?
example: of what I'm trying to produce.
12 03 2010 09 49 33.416
This would represent december 03 2010, 09:49:33.416 am Also how would I create the leading zero's
tia sal22
Dec 3, 2010 8:41 pm
Peter DunihoOn 12/3/10 12:30 PM, ratullloch_delthis wrote:
> Greetings All
>
> I would like to use the current date and time as a serial number in csharp what command or tutorial if there is one should I use?
> example: of what I'm trying to produce.
>
> 12 03 2010 09 49 33.416
>
> I would like to use the current date and time as a serial number in csharp what command or tutorial if there is one should I use?
> example: of what I'm trying to produce.
>
> 12 03 2010 09 49 33.416
That's not a serial number. A serial number would be, for example,
simply taking the value of the DateTime.Ticks property.
What you're asking for is a custom date format. Which you can
accomplish easily using .NET's custom date format codes.
http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx
Pete
Dec 4, 2010 1:09 am
Arne Vajh?jOn 03-12-2010 15:30, ratullloch_delthis wrote:
> I would like to use the current date and time as a serial number in csharp what command or tutorial if there is one should I use?
> example: of what I'm trying to produce.
>
> 12 03 2010 09 49 33.416
> This would represent december 03 2010, 09:49:33.416 am Also how would I create the leading zero's
> example: of what I'm trying to produce.
>
> 12 03 2010 09 49 33.416
> This would represent december 03 2010, 09:49:33.416 am Also how would I create the leading zero's
dt.ToString("dd MM yyyy HH mm ss.fff")
should do that, but:
1) I will suggest "yyyy MM dd HH mm ss.fff" to get a better ordering.
2) Maybe you should consider another way to generate serial
numbers, because on todays fast computers may be very realistic
to create two of something within the same millisecond (often
using database identity/auto increment is a simple way to
achieve true uniqueness)
Arne
Previous Thread: Example tutorial of Frequency/tone generator in csharp tia sal22
Next Thread: Using a namespace for typedefs inheritance problem, 'using' not working.
Related Forum Topics
- Does it exist a function that return hh:mm or date for an input that is number of seconds for a given date
- Intercepting user Date Time change
- Getting the change from Daylight Savings time to Standard time.
- Example tutorial of Frequency/tone generator in csharp tia sal22
- Communication using serial port
- How to Increase ReadBufferSize of serial Port
- How to get the max value for each date group
- I changed a portion of my code from serial to parallel - And it takeslonger
- String.Format newb
- How to make a fancy format