Click here to Skip to main content
15,896,453 members
Home / Discussions / C#
   

C#

 
AnswerRe: Is there a setting in visual studio for the Convert.ToDateTime? Pin
Hunuman9-Nov-06 1:29
Hunuman9-Nov-06 1:29 
GeneralRe: Is there a setting in visual studio for the Convert.ToDateTime? Pin
Support1239-Nov-06 1:44
Support1239-Nov-06 1:44 
GeneralRe: Is there a setting in visual studio for the Convert.ToDateTime? Pin
Colin Angus Mackay9-Nov-06 6:59
Colin Angus Mackay9-Nov-06 6:59 
GeneralRe: Is there a setting in visual studio for the Convert.ToDateTime? Pin
Pete O'Hanlon9-Nov-06 1:45
mvePete O'Hanlon9-Nov-06 1:45 
GeneralRe: Is there a setting in visual studio for the Convert.ToDateTime? Pin
Support1239-Nov-06 2:12
Support1239-Nov-06 2:12 
GeneralRe: Is there a setting in visual studio for the Convert.ToDateTime? Pin
Pete O'Hanlon9-Nov-06 2:27
mvePete O'Hanlon9-Nov-06 2:27 
GeneralRe: Is there a setting in visual studio for the Convert.ToDateTime? Pin
Support1239-Nov-06 2:32
Support1239-Nov-06 2:32 
GeneralRe: Is there a setting in visual studio for the Convert.ToDateTime? Pin
Pete O'Hanlon9-Nov-06 4:14
mvePete O'Hanlon9-Nov-06 4:14 
Naruto

Try the following wrapper class and test:

using System;<br />
using System.Collections.Generic;<br />
using System.Text;<br />
<br />
namespace DateWrapper<br />
{<br />
 public class WrappedDate<br />
 {<br />
  private DateTime? _dt = null;<br />
<br />
  /// <summary><br />
  /// Initialize a new instance of <see cref="WrappedDate"/>.<br />
  /// </summary><br />
  public WrappedDate()<br />
  {<br />
  }<br />
<br />
  /// <summary><br />
  /// Initialize a new instance of <see cref="WrappedDate"/>.<br />
  /// </summary><br />
  /// <param name="dt">The date/time to wrap.</param><br />
  public WrappedDate(DateTime dt)<br />
  {<br />
   _dt = dt;<br />
  }<br />
<br />
  /// <summary><br />
  /// Initialize a new instance of <see cref="WrappedDate"/>.<br />
  /// </summary><br />
  /// <param name="dateOnly">The date part without a time.</param><br />
  public WrappedDate(string dateOnly)<br />
   : this(dateOnly, null)<br />
  {<br />
  }<br />
<br />
  /// <summary><br />
  /// Initialize a new instance of <see cref="WrappedDate"/>.<br />
  /// </summary><br />
  /// <param name="date">The date without the time</param><br />
  /// <param name="time">The time portion.</param><br />
  public WrappedDate(string date, string time)<br />
  {<br />
   if (string.IsNullOrEmpty(time))<br />
    time = "00:00:00";<br />
   if (!time.StartsWith(" "))<br />
    time = " " + time;<br />
   while (time.IndexOf("  ") > -1)<br />
   {<br />
    time = time.Replace("  ", " ");<br />
   }<br />
   try<br />
   {<br />
    _dt = Convert.ToDateTime(date + time);<br />
   }<br />
   catch (Exception ex)<br />
   {<br />
    _dt = null;<br />
   }<br />
  }<br />
<br />
  public DateTime? Date<br />
  {<br />
   get { return _dt; }<br />
  }<br />
<br />
 }<br />
<br />
 class Program<br />
 {<br />
  static void Main(string[] args)<br />
  {<br />
   WrappedDate start = new WrappedDate(DateTime.Now);<br />
   WrappedDate dt = new WrappedDate("20/12/2006", "10:00:00");<br />
   WrappedDate finish = new WrappedDate(DateTime.Now.AddHours(1));<br />
   WrappedDate compare = new WrappedDate(DateTime.Now.AddMinutes(30));<br />
   Console.WriteLine(dt.Date.ToString());<br />
<br />
   if (compare.Date >= start.Date && compare.Date <= finish.Date)<br />
    Console.WriteLine("Success");<br />
   else<br />
    Console.WriteLine("Failure");<br />
   Console.ReadLine();<br />
  }<br />
 }<br />
}



Arthur Dent - "That would explain it. All my life I've had this strange feeling that there's something big and sinister going on in the world."
Slartibartfast - "No. That's perfectly normal paranoia. Everybody in the universe gets that."

Deja View - the feeling that you've seen this post before.

GeneralRe: Is there a setting in visual studio for the Convert.ToDateTime? Pin
Support1239-Nov-06 5:27
Support1239-Nov-06 5:27 
GeneralRe: Is there a setting in visual studio for the Convert.ToDateTime? Pin
Pete O'Hanlon9-Nov-06 9:11
mvePete O'Hanlon9-Nov-06 9:11 
QuestionTo make possible to manage position and size of controls by mouse Pin
wasek20018-Nov-06 23:59
wasek20018-Nov-06 23:59 
AnswerRe: To make possible to manage position and size of controls by mouse Pin
mark_w_9-Nov-06 0:27
mark_w_9-Nov-06 0:27 
QuestionRe: To make possible to manage position and size of controls by mouse Pin
wasek20019-Nov-06 4:31
wasek20019-Nov-06 4:31 
QuestionAbstract collection in property grid Pin
mark_w_8-Nov-06 23:56
mark_w_8-Nov-06 23:56 
AnswerRe: Abstract collection in property grid Pin
Robert Rohde9-Nov-06 0:52
Robert Rohde9-Nov-06 0:52 
AnswerRe: Abstract collection in property grid Pin
mark_w_9-Nov-06 1:27
mark_w_9-Nov-06 1:27 
QuestionWrapping or creating custom XML elements Pin
TUX2K8-Nov-06 23:39
TUX2K8-Nov-06 23:39 
QuestionLike "VS Watch" control Pin
El'Cachubrey8-Nov-06 23:38
El'Cachubrey8-Nov-06 23:38 
Questionhow to select data from the datagrid Pin
Saira Tanwir8-Nov-06 23:22
Saira Tanwir8-Nov-06 23:22 
AnswerRe: how to select data from the datagrid Pin
rah_sin8-Nov-06 23:45
professionalrah_sin8-Nov-06 23:45 
GeneralRe: how to select data from the datagrid Pin
Saira Tanwir9-Nov-06 0:00
Saira Tanwir9-Nov-06 0:00 
GeneralRe: how to select data from the datagrid Pin
rah_sin9-Nov-06 0:15
professionalrah_sin9-Nov-06 0:15 
AnswerRe: how to select data from the datagrid Pin
Saira Tanwir9-Nov-06 0:21
Saira Tanwir9-Nov-06 0:21 
QuestionChange Default Web Site's name of IIS Pin
lambro8-Nov-06 22:48
lambro8-Nov-06 22:48 
AnswerRe: Change Default Web Site's name of IIS Pin
TUX2K8-Nov-06 23:51
TUX2K8-Nov-06 23:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.