views:

62

answers:

3

Hi all,

I need to convert the system datetime to timestamp in script task SSIS.

input date format: 29/05/2010 2:36 AM

output format: 29-15-2010 14:36:00

thanks prav

+1  A: 

The output doesn't quite match the input (the month becomes 15, and it goes from AM to PM). I assume those are typos. It should be something like:

string output = DateTime.ParseExact(input, "dd/MM/yyyy h:m tt", null).ToString("dd-MM-yyyy HH:mm:ss");

If it's user input, you may want TryParseExact instead.

Matthew Flaschen
+1  A: 

Hi,

Givig the format of output into the string method gives the timestamp results.

string dt = DateTime.Now.ToString("yyyy'-'MM'-'dd' 'HH':'mm':'ss");

        DateTime dateformat = Convert.ToDateTime(dt);
        Console.WriteLine(dt);
        Console.WriteLine(dateformat);
        Console.ReadLine();

thanks prav

praveen
A: 
       DateTime.Parse(input).ToString("dd-MM-yyyy HH:mm:ss")
filip-fku