C# forum for web developers

Using current date and time format as serial number tia sal22

Dec 3, 2010 8:30 pm
Ratullloch_delthis

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
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 Duniho
Re: using current date and time format as serial number tia sal22

On 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

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?j
Re: using current date and time format as serial number tia sal22

On 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

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
Intercepting user Date Time change
I would need a method within my program to intercept
a user attempt to change the time or date of the pc.

In such a case a need to inform him and prevent the change time date
change
while the program is running .

How can i do that ? Any example ?

-P


(reason: this is a trading...
Getting the change from Daylight Savings time to Standard time.
Hi

We do this twice a year, but in the autum, we turn our clocks back,
and usually the hour 2 or 3 repeats itself.
This is a problem for a data handler of my, which should not do this
when the hour happens the first time.

I an older Delphi version, I used GetTimeZoneInformation to get...
Example tutorial of Frequency/tone generator in csharp tia sal22
Greetings all
I'm trying to find a tutorial that shows me how to make a Frequency/tone generator in Csharp (C#)
Example I would like to have a slider that changes the value of x for the formula y=sin(x) so if the slider is moved
to 440 it would play a 440hz sin wave out the speaker does such a...
Communication using serial port
Hi,
I am working on serial port communication wherein i am sending

serialPort1.Write(Hex2Ascii("3A08007A00564953494F4E3336[3DC2]0D0A"));
Thread.Sleep(400);
string resp = serialPort1.ReadExisting();
resp = resp.Substring(5, 2);
...
How to Increase ReadBufferSize of serial Port
hi,
I have to read around 6k data from serialport communication. but
i am able to read only 4k. I have even set ReadBufferSize of
serialport to 10k even then it is reading only 4k using ReadExisting()
method of serialport.

thank u
with regards,
Om


How to get the max value for each date group
I have a typed dataset with several columns but there are only two that are
of interest here. They are myDate and myLoopnrdag
I want to find the maximum value of myLoopnrdag for each group of mydate.

In this example I want to find 11 for myDate 2013-05-03 and
9 for myDate 2013-05-05...
I changed a portion of my code from serial to parallel - And it takeslonger
According to the Eqatec Profiler and my own eyes, the serial code runs
faster slightly than the parallel code. This despite confirmation that
each parallel thread is running half as many items.

The only thing I can think of is that the list they are both accessing
is locking when each...
String.Format newb
given
Excel.Range rng1 = _xlWorkSheet.get_Range(rangeName, Type.Missing);
string cash = String.Format("{0: ###,###.##}",
rng1.Value2);

I get the string "123,546"
but it should be "123,546.00"

what am i doing wrong?
thanks
mark




How to make a fancy format
Hello!

Here is the code that update the listBox but there is a small problem. When
I have different number of item in the foodList will the position for the
column title not be lined up the the data. How do I best solve this lined up
between the column title and the data for the...