473,395 Members | 1,677 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Day name of date object not working

In my csharp code behind file, I'm trying to perform a redirect if the
date a user queries is a Wednesday:

string rqs = Request.QueryString["txtboarddate"];
string rqsday;
rqsday = (System.String.Format("{0:dddd}",rqs)) ;
if(rqsday == "Wednesday")
{
Response.Redirect("http://www.anothersite.com");
}

...but when the date (take today which is a Wednesday) is queried from
the prior page (everything on that page is formatted correctly because
it works when pointing to other functions of the script), I do not get
the redirect. When I comment out the "if" coding, the redirect does
work.

????
..Net Sports

Nov 17 '05 #1
4 3430
..Net Sports <ba********@cox.net> wrote:
In my csharp code behind file, I'm trying to perform a redirect if the
date a user queries is a Wednesday:

string rqs = Request.QueryString["txtboarddate"];
string rqsday;
rqsday = (System.String.Format("{0:dddd}",rqs)) ;
if(rqsday == "Wednesday")
{
Response.Redirect("http://www.anothersite.com");
}

..but when the date (take today which is a Wednesday) is queried from
the prior page (everything on that page is formatted correctly because
it works when pointing to other functions of the script), I do not get
the redirect. When I comment out the "if" coding, the redirect does
work.


Well, the first thing to do is log what the value of rqsday is...]

Bear in mind that Wednesday isn't called Wednesday in all cultures, and
IIRC the above will format the date in the detected culture of the
browser.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #2
Your approach seems not to be the best : you shouldn't compare strings
when you can. You have the DateTime.DayOfWeek property which can be
helpful. Just parse your txtboarddate variable with DateTime.Parse and
voila ;-)

On Wed, 13 Jul 2005 23:06:53 +0200, .Net Sports <ba********@cox.net> wrote:
In my csharp code behind file, I'm trying to perform a redirect if the
date a user queries is a Wednesday:

string rqs = Request.QueryString["txtboarddate"];
string rqsday;
rqsday = (System.String.Format("{0:dddd}",rqs)) ;
if(rqsday == "Wednesday")
{
Response.Redirect("http://www.anothersite.com");
}

..but when the date (take today which is a Wednesday) is queried from
the prior page (everything on that page is formatted correctly because
it works when pointing to other functions of the script), I do not get
the redirect. When I comment out the "if" coding, the redirect does
work.

????
.Net Sports


Nov 17 '05 #3
I'm not sure I understand. Request.QueryString["txtboardd*ate"] comes
from the previous page as "7/13/2005" (if querying a Wednesday date). I
want to make 'rqsday' the day name of 'rqs' (which is
Request.QueryString["txtboardd*ate"] )

Nov 17 '05 #4
Well, first of all, somewhere in your code, you are going to have to use
a DateTime object. All you are using now are strings.
rqsday = (System.String.Format("{0:dddd}",rqs)) ;
will accomplish exactly the same thing as
rqsday = rqs;

You probably want:
DateTime rqs = DateTime.Parse(Request.QueryString["txtboarddate"]);
(note, that could throw an exception)

--
--
Truth,
James Curran
[erstwhile VC++ MVP]

Home: www.noveltheory.com Work: www.njtheater.com
Blog: www.honestillusion.com Day Job: www.partsearch.com

".Net Sports" <ba********@cox.net> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
In my csharp code behind file, I'm trying to perform a redirect if the
date a user queries is a Wednesday:

string rqs = Request.QueryString["txtboarddate"];
string rqsday;
rqsday = (System.String.Format("{0:dddd}",rqs)) ;
if(rqsday == "Wednesday")
{
Response.Redirect("http://www.anothersite.com");
}

..but when the date (take today which is a Wednesday) is queried from
the prior page (everything on that page is formatted correctly because
it works when pointing to other functions of the script), I do not get
the redirect. When I comment out the "if" coding, the redirect does
work.

????
.Net Sports

Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Martin | last post by:
I'd like to be able to get the name of an object instance from within a call to a method of that same object. Is this at all possible? The example below works by passing in the name of the object...
1
by: Prasad Karunakaran | last post by:
I am using the C# DirectoryEntry class to retrieve the Properties of an user object in the Active Directory. I need to get the First Name and Last Name as properties. I know it is not supported...
6
by: Trevor Hartman | last post by:
Hi, I need to refer to my objects dynamically. I have a 7 table cells (sunCell, monCell, tueCell....). I am looping through some data, checking its date and adding it to the correct cell. I...
7
by: Jerome | last post by:
Hallo, I know a lot has already been told about date/time fields in a database but still confuses me, specif when dealing with SQLserver(Express). It seems that sqlserver only accepts the date in...
5
by: Kermit Piper | last post by:
Hello, I am comparing two date values, one from a database and one that has been converted from a hard-coded string into an actual Date type. So far so good. The problem I'm having is that one...
2
by: bryan.a.fowler | last post by:
I'm really new working with VB.net and I'm working on a simple program with a date input. I've got a couple of questions; 1) I'm using a DateTimePicker to show both the user inputted date as...
4
by: sck10 | last post by:
Hello, What I am trying to do is get the string(August) from: hdnMonth.Value = DateTime.Now.Month.ToString(); Does c# have a function like the vb function "MonthName" ? hdnMonth.Value =...
10
by: Daniel | last post by:
In Microsoft Access I can write a query that includes the criteria: Between Date()-7 And Date() to retrieve the records from a table that fall within the last week. I'm trying to write a...
4
by: TS | last post by:
i am wondering why the name of the controls are listed in parameters of request object instead of ID. The name always uses the default '$' for encapsulations and the ID uses '_'. When i use...
10
by: =?Utf-8?B?SmFtZXMgV29uZw==?= | last post by:
Hi everybody, I'm trying to use the new VB 2008 right now and I want to know how to preset the company name and copyright informtion in Assembly Information. In my current VB 2005, company name...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.