locked
datetime function RRS feed

  • Question

  • User120878812 posted

    I have one table timetrack which contains dateofwork,startTime,endtime column names.I want to take only month from the 'dateofwork' and match the current years month.I also want to date difference of that dateofwork which has the current month.I am using the mysql server and asp.net windows application.Please help me......

    Tuesday, March 13, 2012 7:28 AM

Answers

  • User1829879277 posted

    Try:

    Inside loop...

    DateTime dtDBDate = new DateTime(03,13,2011); // Date dateofwork fetched from the DB

    string strDBMonth = dtDBDate.Month.ToString();

    if (dtDBDate.Month == DateTime.Now.Month)

    {

        TimeSpan tsDateDiff = DateTime.Now.Subtract(dtDBDate);<o:p></o:p>

    }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, March 13, 2012 7:53 AM

All replies

  • User2105156359 posted

    HI

    CHeck the following link...it contains the useful conversion of DateTime in a table

    http://www.sqlusa.com/bestpractices/datetimeconversion/

    Tuesday, March 13, 2012 7:38 AM
  • User1829879277 posted

    Try:

    Inside loop...

    DateTime dtDBDate = new DateTime(03,13,2011); // Date dateofwork fetched from the DB

    string strDBMonth = dtDBDate.Month.ToString();

    if (dtDBDate.Month == DateTime.Now.Month)

    {

        TimeSpan tsDateDiff = DateTime.Now.Subtract(dtDBDate);<o:p></o:p>

    }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, March 13, 2012 7:53 AM