Community discussion forum

How to convert a string to a date

This is a comment thread discussing How to convert a string to a date
  • 9 years ago

    This thread is for discussions of How to convert a string to a date.

  • Advertisement

    Simply the fastest line-level profiler for .NET ever

    “The low overhead means it has minimal impact on the execution of my program”
    Mark Everest, Development Team Leader, Renault F1 Team Ltd.

    Try out the new ANTS Profiler 4 for yourself. Download your 14-day trial now

  • 5 years ago

    DateTime dtDate = Convert.ToDateTime(strDate);


    "Convert" is a class in a "System" namespace.

  • 5 years ago

    Another Way is Also
    DateTime dt = DateTime.Parse(strdate);



  • 5 years ago

    'Make sure that your date is correct, if you try for example to do "11/31/03"
    'you will get an error because november only has 30 days to it the correct string
    'is "11/30/2003"


    dim dateString as string = "11/30/2003"


    dim convertedDate as Date = CDate(dateString)

  • 4 years ago

    How can i get just date part (22/12/2003) out of datetime(22/12/2003/ 1:23:00 PM) without convert to string datetypes (ShortDateString etc).
    for instance if ur passing datetime parameters to stored procedures that perform search based on dates supplied.
    Passing dates with time would not show last record coz it compares with time too.


  • 3 years ago

    I've tried this piece of code:


    DateTime startTime;


    start = Convert.ToDateTime(startTimePicker.Text);


    Console.WriteLine(startTime.ToLongTimeString());


    The problem with this is that the results are string values but i want the actual time value in order to be able to use it to compare times to prevent overlaps in meeting times.

  • 3 years ago

    Svy,
    Cheers mate that one had thus far eluded me.

  • 3 years ago

    Hey, to ALL Developers and Programmers,

     

      Here's a simple and easy way of solving all your Date Programming and Conversion  problems.


    Developer's Dateware offers a much greater variety of date features, versus what is offered in typical programming environments.  You will not need to fuss with the PC's Locale system any longer – these features will do it for you.  These Date functions range from general areas to specific areas.


    Developer's Dateware offers: 
       1)  simplicity in performing any kind of Date Operation.
       2)  much more capabilties,  for a lot less money.
       3)  Excellent
    Results and Performance are Guaranteed .
                   And yet, we’ll beat the rest! 
       4)   supports many different date formats... 

    Are you ready to take a challange for something new and much better?

     

    DateFormats,      and yes, I’m still around…

     

    The software is written in MSVC++ v6.0,  (with NO MFC Code).

     

    For Further Details about Developer's Dateware Software and demo,

            contact Thad at:  auroraprojectusaf@yahoo.com

       --6/22/2008--

  • 1 year ago

    'Converts the date in format dd/MM/yyyy to date format in MM/dd/yyyy

    Dim stDate As String = "31/12/2006"

    Dim dtDate As Date

    dtDate = DateTime.Parse(stDate, Globalization.CultureInfo.CreateSpecificCulture(

    "en-CA"))

    MsgBox(dtDate)

Post a reply

Enter your message below

Sign in or Join us (it's free).