user584018
user584018

Reputation: 11304

Date Time Issue

the data table (C#) returns date/time (with AM/PM) column with below data,

08/01/2011 5:16:02 PM
07/27/2011 9:31:26 PM

how to convert the same to string data type in C#?

in SQL, i can convert datetime to string by below, but how to convert in C#....?

ISNULL(CASE WHEN CONVERT(CHAR(10),FirstCommunicationDate,108)<'12:00:00'  THEN CONVERT(VARCHAR(11),FirstCommunicationDate,101)+ SUBSTRING(CONVERT(VARCHAR(20),FirstCommunicationDate,109),12,15) + ' AM'
            ELSE CONVERT(VARCHAR(11),FirstCommunicationDate,101)+ SUBSTRING(CONVERT(VARCHAR(20),FirstCommunicationDate,109),12,15) + ' PM' END, '') AS FirstCommunicationDate

Upvotes: 0

Views: 111

Answers (1)

You can use DateTime.ToString() Method for this Purpose.

Upvotes: 3

Related Questions