so i have a stored proc that i am passing in datetime params too return the data... The problem is i want to pass in default dates and times but not sure how to do this as i can only see datetime.now... here is my code...
public void RefreshLabeldata(int selectedProduct, DateTime shiftStart, DateTime shiftEnd)
{
BizManager biz = new BizManager();
DataSet dt = new DataSet();
dt = biz.GetTotalPacked(
shiftStart
, shiftEnd
, selectedProduct).DataSet;
labeltotal.Text = dt.Tables[0].Rows[0]["TotalPacked"].ToString();
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Refreshdata(214, DateTime.Today, DateTime.Today.AddDays(1).AddMinutes(-1));
BindDropDownList();
RefreshLabeldata(214, DateTime.Today , DateTime.Today);
...
}
...
}
I want to pass in the date that my sql stored proc accepts i.e shiftStart 2016-06-06 06:00 shiftEnd 2016-06-06 14:00.
I know my datetimes are all wrong :) i am still trying to figure this part out.
If you are learning how to pass DateTime as a parameter then please go through DateTime documentation. Here
DateTime.Todaywill contain value something like6/6/2018 12:00:00 AM. If you know exact date and time, then instead of usingDateTime.Todayyou can useDateTime.ParseExact(dateString, format, provider).where dateString will be your date in string format.
format will contain date time format e.g.
"yyyy-MM-dd".provider will be cultureInfo. For more details MSDN
To summarize, try with