How i can Change my date into yyyy-mm-dd format and this From and to are parameters of SQL Stored Procedure .so please tell me what i do
txt_from.Text='01/08/2015';
txt_to.Text='03/08/2015';
DateTime from = new DateTime(Convert.ToInt32(txt_from.Text.Split('/')[2]), Convert.ToInt32(txt_from.Text.Split('/')[1]), Convert.ToInt32(txt_from.Text.Split('/')[0]));
DateTime to = new DateTime(Convert.ToInt32(txt_to.Text.Split('/')[0]), Convert.ToInt32(txt_to.Text.Split('/')[1]), Convert.ToInt32(txt_to.Text.Split('/')[2]));
if (to > Convert.ToDateTime(DateTime.Now.ToShortDateString()))
{
RegisterClientScriptBlock("alert", "");
}
else
{
to = to.AddDays(1);
if (from <= to)
{
SqlParameter[] param = new SqlParameter[]
{
new SqlParameter("@from",from),
new SqlParameter("@to",to),
new SqlParameter("@PortalId",Convert.ToInt32( Session["PortalId"]))
};
{
RegisterClientScriptBlock("alert", "");
}
else
{
to = to.AddDays(1);
if (from <= to)
{
SqlParameter[] param = new SqlParameter[]
{
new SqlParameter("@from",from),
new SqlParameter("@to",to),
new SqlParameter("@PortalId",Convert.ToInt32( Session["PortalId"]))
};

Mageshwaran RRank #411 · 6.1K reputationPosted Nov 12, 2019, 1:44 AM EST
Amitesh VermaRank #2,535 · 552 reputationPosted Aug 3, 2015, 4:14 AM EDT
IFormatProvider culture = new CultureInfo("en-US", true);
Upendra Pratap ShahiRank #329 · 7.5K reputationPosted Aug 3, 2015, 4:24 AM EDT
string DateString = "11/12/2009";
IFormatProvider culture = new CultureInfo("en-US", true);
DateTime dateVal = DateTime.ParseExact(DateString, "yyyy-MM-dd", culture);
Rajeesh MenothRank #118 · 18.4K reputationPosted Aug 3, 2015, 4:37 AM EDT
//Put thiz code
using System.Globalization;
Ref this : https://rajeeshmenoth.wordpress.com/2014/11/12/string-was-not-recognized-as-a-valid-datetime/DateTime From = DateTime.ParseExact(txtFrom.Text, "yyyy/mm/dd", CultureInfo.InvariantCulture);
Abhay ShankerRank #375 · 6.7K reputationPosted Aug 3, 2015, 8:13 AM EDT
string format = "dd/mm/yyyy";
DateTime dateTime = DateTime.ParseExact(dateString, format, CultureInfo.InvariantCulture);
string strNewDate = dateTime.ToString("yyyy-dd-mm");
shankar naspuri22 reputationPosted Sep 18, 2019, 4:29 AM EDT
Jaimin ShethiyaRank #177 · 13.7K reputationPosted Sep 23, 2019, 9:03 PM EDT
can you convert date in SQL side and after checked.
here is the example same as the your format
also refer this below links for other format in future and let me know if you have needed any other help.
Thanks
Apurva SinghRank #6,113 · 276 reputationPosted Sep 23, 2019, 9:22 PM EDT