.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old May 4th, 2004, 03:35 PM
scurenton scurenton is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 2 scurenton User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Lightbulb HELP! Date comparison

OK - 'm working with the Calendar control DayRender event. First My code, then the problem:

Code:
 
privatevoid DayRender(object sender, System.Web.UI.WebControls.DayRenderEventArgs e)

{

tempDate = e.Day.Date;//Calendar1.TodaysDate;

string selectData = "SELECT Meeting_Title, Meeting_date=convert(datetime,convert(char(10),Mee  ting_date,101))FROM Meeting_Profile_tbl";

SqlDataAdapter da = new SqlDataAdapter(selectData, conn2);

DataSet ds = new DataSet();

da.Fill(ds, "Meeting_Profile_tbl");

DataTable dt = ds.Tables["Meeting_Profile_tbl"];

foreach (DataRow dr in dt.Rows)

{

string myDate = dr[1].ToString();-------PROBLEM IS SOMEWHERE IN HERE



if (myDate == tempDate.ToString())

{

e.Cell.Controls.Add(new LiteralControl("Meeting"));

 }

}

conn2.Close();

}

 


I'm getting "myDate" out of SQL and when I bring it in the format of the date is mm/dd/yyyy hh:mm:ss and I am trying to compare it with the DayRendered date which is in mm/dd/yyyy only.

How in the world can I convert the dates to match formats. As you can see from my SELECT statement above, I am trying to convert within the statement but it doesn't work. If anyone can help me through this, I will consider you DA MAN or WOMAN which ever

Reply With Quote
  #2  
Old May 5th, 2004, 03:48 AM
majk majk is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 3 majk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Try this:
Format the date in the datarow before you do the test:
Declare a DateTime variable datetime
datetime = dr[1].ToString();
Then format it and put it back before you do the comparison
dr[1] = datetime.ToShortDateString() (or something..)

I do it in vb.net so I'm not sure exactly how to do it in C# but I hope it helps.
/majk

Reply With Quote
  #3  
Old May 5th, 2004, 09:29 AM
pmuk pmuk is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Location: USA
Posts: 21 pmuk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Smile HELP! Date comparison

Try with CDate() function.

Hope it helps...

Rgds,
pmuk

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgramming.NET Development > HELP! Date comparison


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway