bulgarian388
01-21-2007, 07:08 PM
Hi dudes, I have a bit of a problem that has been pissing me off for the past hour now. I have a form that posts back to its' self to view a traffic log. In the form are two fields, "startDate" and "endDate". The data is stored in MySQL so I have to convert the user input to something MySQL likes:
1/1/2007 = 2007-01-01
Problem is that I'm not getting anywhere with it. Here is the code I'm using:
String startDate = Request.Form["startDate"];
if (startDate == null) {
DateTime tempDate = DateTime.Now.AddDays(-1);
} else {
DateTime tempDate = Convert.ToDateTime(startDate);
}
startDate = Convert.ToString(tempDate.Year + "-" + tempDate.Month + "-" + tempDate.Day);
I keep getting this error when I try to run it:
"CS0103: The name 'tempDate' does not exist in the current context"
It's driving me insane right now. I am trying to port it over from ASP classic where I just did this:
startDate = request.Form("startDate")
if startDate = "" or isnull(startDate) then
startDate = dateAdd("d", -1, date())
end if
startDate = year(startDate) & "-" & month(startDate) & "-" & day(startDate)
If anyone knows the answer, I would really appreciate it if you could let me know.
Thanks in advance.
1/1/2007 = 2007-01-01
Problem is that I'm not getting anywhere with it. Here is the code I'm using:
String startDate = Request.Form["startDate"];
if (startDate == null) {
DateTime tempDate = DateTime.Now.AddDays(-1);
} else {
DateTime tempDate = Convert.ToDateTime(startDate);
}
startDate = Convert.ToString(tempDate.Year + "-" + tempDate.Month + "-" + tempDate.Day);
I keep getting this error when I try to run it:
"CS0103: The name 'tempDate' does not exist in the current context"
It's driving me insane right now. I am trying to port it over from ASP classic where I just did this:
startDate = request.Form("startDate")
if startDate = "" or isnull(startDate) then
startDate = dateAdd("d", -1, date())
end if
startDate = year(startDate) & "-" & month(startDate) & "-" & day(startDate)
If anyone knows the answer, I would really appreciate it if you could let me know.
Thanks in advance.