Link to home
Start Free TrialLog in
Avatar of vishnunarayan
vishnunarayan

asked on

milliseconds in Date

Hi,

I have a class "date.cs" in which a property modifieddate is of the type DateTime.

In another class i am trying to read a datevalue from a datagridview which is populated from the database.

The database table has milliseconds in all its date columns.
When i try to read the date value from the datagridview and assign it to the modifieddate of the date.cs class the milliseconds value doesnt get assigned because of which i am facing errors.

How do i solve this problem of fetching the milliseconds value.


My piece of code

string modDate = Convert.Todatetime(dtv.rows[0].cells["datecolumn"].value.tostring("yyyy-MM-dd HH:mm:ss:fff"));

Datetime getDate = DateTime.ParseExact(modDate,"yyyy-MM-dd HH:mm:ss:fff",culture);
where culture :
CultureInfo culture = System.Threading.Thread.CurrentThread.CurrentCulture;

and i assign this getDate to the modifieddate of the date.cs file.
At this time i am loosing the milliseconds part.
ASKER CERTIFIED SOLUTION
Avatar of mjmarlow
mjmarlow
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial