locked
Convert to int & Date RRS feed

  • Question

  • User1979860870 posted

    Hi

      I have below 2 lines . First line Column is int & second is Date. How we can check for Null value also.

    text1 += dr[6].ToString() + "</td><td> ";
    text1 += dr[7].ToString() + "</td><td> ";

    I want int column to display to 2 decimal places

    Date Column in dd/MM/yyyy format

    Thanks

    Wednesday, December 30, 2020 7:12 AM

Answers

  • User1535942433 posted

    Hi jagjit saini,

    I want int column to display to 2 decimal places

    Date Column in dd/MM/yyyy format

    Convert int  to decimal:

    int i= 1;
    decimal d = Convert.ToDecimal(i);
    decimal dc= Math.Round(d, 2);

    Convert date to  date format dd/mm/yyyy:

    DateTime date = new DateTime(2020,12,31);
    string formatted = date.ToString("dd/M/yyyy");

    Best regards,

    Yijing Sun

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, December 31, 2020 6:13 AM