Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to convert datetime in format 23:59:59

I'm having two dates FromDate and toDate

converting dates like following and passing as parameters to stored procedure:

both variable are of DateTime FromDate, DateTime toDate variables

initial values coming like {10/1/2013 12:00:00 AM}

I have converted that using below code to {10/1/2013 00:00:00}

  sparamFromDate.Value = FromDate.ToString("yyyy-MM-dd HH:mm:ss");

  sparamToDate.Value = toDate.ToString("yyyy-MM-dd HH:mm:ss");

which is giving me expected result for FromDate as : 2013-10-11 00:00:00.000

But I need a todate in following format how can i convert this in code?

toDate : 2013-10-11 23:59:59.000

like image 308
Neo Avatar asked Dec 06 '25 21:12

Neo


1 Answers

toDate.ToString("yyyy-MM-dd 23:59:59.000");

It doesnt matter if toDate is just the date or has a time component - the output will be the same and what you want.

like image 144
wal Avatar answered Dec 09 '25 19:12

wal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!