Monday, March 26, 2012

Passing in a default parameter date via a URL

Hi Guys,

What is the syntax for passing in a default parameter of current date via a URL.

cheers

If you don't want to have to deal with IFormatProvider and DateTimeStyles of DateTime.Parse() method, then you can simply use the "MM/dd/yyyy" format. For example:

string dateToConvert = "12/25/2006";
DateTime today = DateTime.Parse(dateToConvert);

So, in your url, simply do: myPage.aspx?date=12/25/2006

Then retrieve the query string (Request.QueryString["date"]), check to make sure it's not null and not empty, and then finally convert it using the above mentioned DateTime.Parse(...).|||

Thanks jcasp.

This isn't quite what I meant. I want the currentdate to be passed in which I do not know of beforehand. Usually in VB I use Now or Date what is the equivalent.

Cheers

|||

Hi,

you can use DateTime.Now in .NET.

Grz, Kris.

No comments:

Post a Comment