in Education by
This is confusing, all I want is the Time from DateTime ? here is my code: clsdbo_RR.DateRecd = reader["DateRecd"] is DBNull ? null : (DateTime?)reader["DateRecd"]; clsdbo_RR.TimeRecd = reader["TimeRecd"] is DBNull ? null : reader["TimeRecd"].ToString("hh:mm:ss"); My date appears as date correctly but the time is not showing up? private Nullable m_TimeRecd; public Nullable DateRecd { get { return m_DateRecd; } set { m_DateRecd = value; } } JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
I strongly suspect that your reader["TimeRecd"] returns object, that's why you need to cast it to DateTime (or DateTime? as you did) first before you call ToString method. Without casting, it probably calls object.ToString method, not DateTime.ToString. If your clsdbo_RR.TimeRecd is string, you just need to use (DateTime?)reader["TimeRecd"].ToString("hh:mm:ss") instead like; clsdbo_RR.TimeRecd = reader["TimeRecd"] is DBNull ? null : (DateTime?)reader["TimeRecd"].ToString("hh:mm:ss");

Related questions

0 votes
    This is confusing, all I want is the Time from DateTime ? here is my code: clsdbo_RR.DateRecd = ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    I have a problem. DataGridView displays only date if time is midnight. First I thought that is because of ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 19, 2022 in Education by JackTerrance
0 votes
    In my XSLT stylesheet I extract the value of the current month using a month-from-dateTime like this . ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 17, 2022 in Education by JackTerrance
0 votes
    SELECT GETDATE() Returns: 2008-09-22 15:24:13.790 I want that date part without the time part: ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 16, 2022 in Education by JackTerrance
0 votes
    SELECT GETDATE() Returns: 2008-09-22 15:24:13.790 I want that date part without the time part: 2008-09-22 00: ... How can I get that? Select the correct answer from above options...
asked Jan 28, 2022 in Education by JackTerrance
0 votes
    Four cards are drawn at a time from a pack of 52 playing cards. Find the probability of getting all the four cards of the same suit. Select the correct answer from above options...
asked Nov 15, 2021 in Education by JackTerrance
0 votes
    How do I parse a string eg. "01/21 - 02/20" which is represented as month/day to month/day. ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 14, 2022 in Education by JackTerrance
0 votes
    I am using Classic ASP and have the following VB script code From8to14 = date-14 To8to14 = date-8 This sets the two ... "& Day(From8to14) &"' " & _ "AND INTRAY.DateMatched...
asked Jul 6, 2022 in Education by JackTerrance
0 votes
    I have configured my timezone in settings, as America/Guatemala and I have some datetime fields in my ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 30, 2022 in Education by JackTerrance
0 votes
    How do I parse a string eg. "01/21 - 02/20" which is represented as month/day to month/day. ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 18, 2022 in Education by JackTerrance
0 votes
    This question already has answers here: Convert pandas DateTimeIndex to Unix Time? (7 answers) Closed 3 ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 26, 2022 in Education by JackTerrance
0 votes
    I have a question. If created_at in my database is datetime and I want to make a query like this ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 19, 2022 in Education by JackTerrance
0 votes
    I have a question. If created_at in my database is datetime and I want to make a query like this ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 17, 2022 in Education by JackTerrance
0 votes
    I have a question. If created_at in my database is datetime and I want to make a query like this ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 14, 2022 in Education by JackTerrance
0 votes
    I have a table which contains 'NULL' values which are of type 'Datetime'. Now i have to convert ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 22, 2022 in Education by JackTerrance
...