Link to home
Start Free TrialLog in
Avatar of r3nder
r3nderFlag for United States of America

asked on

putting PM in a DateTime format in a winform

I have a sql statement that I am trying to put a start date and an end date into. The startdate is DateTime.Today - because that returns MM/dd/yyyy 12:00:00 AM
I need the end date to be MM/dd/yyyy 11:59:59 PM  - How is this done? When I use tt it returns AM
        private void radButton1_Click(object sender, EventArgs e)
        {

            DateTime tempend = DateTime.Today;
            string format = "MM/dd/yyy 11:59:59 tt";

            string end = tempend.ToString(format);
            DateTime start = DateTime.Today;

            string newuserid = iuserid.ToString();
            string conString = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();
            string sqlstr = "delete from ARoles where useruid ='" + newuserid + "' and LastEditDate between '" + start + "' and  '" + end + "'";
            HelperClasses.SqlHelper.ExecuteNonQuery(conString, CommandType.Text, sqlstr);
            this.Close();
        }

Open in new window


I would appreciate the help
Thanks R3nder
ASKER CERTIFIED SOLUTION
Avatar of Obadiah Christopher
Obadiah Christopher
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of r3nder

ASKER

Thank you - worked like a champ - didnt think of adding a day and minusing 1 second :)