views:

37

answers:

1

Hello All,

I have a question related with dataset. I wonder why am I reading wrong value from a dataset?

The field that I want to read has the value of: 2010-06-28 21:00:00

However, when I'm trying to read the first row using:

DateTime endShift = Convert.ToDateTime(ds.Tables[0].Rows[0]["rep_time_to"]);

I get: 04/07/2010 9:00:00 PM

As you can see this value is correct except the date.

Why should I do to get the correct value which is 2010-06-28 21:00:00?

Thanks in advance.

A newbie programmer!

A: 

Some questions:

  1. What's your current culturecode
  2. Why are you storing a date not as a datetime or equivalent?
  3. What is the actual field type?

Some hints: 1. Convert the db value to a string if it isn't already. 2. Try DateTime.Parse 3. Change your DB field to datetime or equivalent, to avoid conversion.

Jeroen