Dear Friends,
Good Day to every one of you............
I have a registration page to create the users..In this it has Issue date and Expiry date of user accessing the application.
I have set, Issue date will be the system date and for Expiry date administrator will choose it for the user.
For Expiry date I have a textbox with Ajax Calendar Extender....when i click on submit the expiry date is storing in database as 11/30/2012
But my requirement is.....
I want to display date as dd/MM/yyyy Format using label...I have used LABEL.
This is my code....Please help.
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(_connString);
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandText = "select datediff(dd,getdate(),ExpiryDate) as Edays, CONVERT(varchar, expirydate, 101) as ExpiryDates from dbo.UserAccounts where UserName='" + Session["UserName"].ToString() + "'";
using (con)
{
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
if (reader.Read())
{
lblExpiryDisplay.Text = "Your Password will Expire on " + reader["ExpiryDates"].ToString() + " , and the Left Over days are " + reader["Edays"].ToString();
}
}
con.Close();
}