PDA

View Full Version : [C#]Conversione numero in data


RaouL_BennetH
13-03-2008, 18:01
Ariekkime....

Ho un numero formato cosė: 20080301

e dovrei convertirlo in : 01-03-2008 oppure 01/03/2008 ...

E' possibile?

Grazie :)

RaouL.

kernel::panic
13-03-2008, 18:33
Con l'oggetto DateTime:

Console.WriteLine(DateTime.ParseExact(20080301.ToString(), "yyyyMMdd", null).ToString("yyyy-MM-dd"));

Oppure con le stringhe:

Console.WriteLine(20080301.ToString().Insert(4, "-").Insert(7, "-"));


Byez :)

RaouL_BennetH
13-03-2008, 18:41
Grazie mille :)