0

I want to show date in a FORM, but when i running in browser i get this value

/Date(1087789832000)/ 

in my model I make the datatype of the date is:

public DateTime? DueDate { get; set; }

in database I use SQLServer , Datatype is DateTime Too.

i already trying to use convert it in My controller like this, but it's not work :

DueDate = item.DueDate.HasValue ? item.DueDate.Value.ToString("MM/dd/yyyy") : "",

and i get error :

Cannot implicity convert type 'string' to 'System.DateTime'

anybody can help me to how fix this ?? i want convert it in MM/dd/yyyy

Fitre
  • 31
  • 1
  • 2
  • 7
  • Either on the client as per the dupe, or you need to add a `string` property to you model and assign the `.ToString("MM/dd/yyyy")` value to it –  Aug 03 '17 at 08:00
  • @StephenMuecke yes, i have already trying like you mean, but i've got another error in my query, this my query , do you think there is mistake from my query ? **string query = "SELECT A.TtsId, A.InstrumentCode, B.InstrumentFName, B.ISINCode, B.SubTypeCode, A.DueDate, A.ExDate, A.BksClsDate, A.DeclDate, A.DivType, A.Dividend, A.TaxRate, A.Ratio FROM TTransSchedule As A INNER JOIN TInstrument As B ON A.InstrumentCode = B.InstrumentCode WHERE (A.InstrumentCode = '" + instrumentCode + "') AND (A.TtsId = '" + ttsId + "') ";** – Fitre Aug 03 '17 at 08:05
  • That's a completely different question, so ask a new question (including the detail of the error) –  Aug 03 '17 at 08:08
  • String value = DueDate.ToString("MM/dd/yyyy"); – Wing Kui Tsoi Nov 29 '18 at 07:29

0 Answers0