datetime - date only
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Thread: datetime - date only

  1. #1
    Join Date
    Jul 2010
    Posts
    3

    Question datetime - date only

    Hi

    I have a mod.Start datetime value that I want to be displayed like so... Thursday, 15 July 2010


    I am using the following code.....


    Code:
             string modStart;
             modStart = (mod.Start.ToString("dddd, dd MMMM yyyy")); 
    
             if (mod != null)
             {
                return mod.Name + " (" + mod.Reference + ") - " + modStart;
             }
             return "";

    however i get the following error.....

    Compiler Error Message: CS1501: No overload for method 'ToString' takes '1' arguments



    What is wrong?

    I can get the following to work but it returns the date like so...15/07/2010

    ideally i want the date in the other format, above


    Code:
            string modStart;
            modStart = (mod.Start.ToString()); 
            modStart = modStart.Substring(0, 10);

    Please advise, thank you in advance :-)
    Last edited by HanneSThEGreaT; July 22nd, 2010 at 07:26 AM. Reason: Added [CODE] tags.
    Share on Google+

  2. #2
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,074

    Re: datetime - date only

    Please make use of [CODE] tags when posting code.
    Share on Google+

  3. #3
    Join Date
    Feb 2005
    Location
    Denmark
    Posts
    742

    Re: datetime - date only

    And your "Start" is a datetime and not just a string representation of a datetime?
    Share on Google+

  4. #4
    Join Date
    Jul 2010
    Posts
    3

    Re: datetime - date only

    Hi Alsvha

    Yes, Start is a datetime value, for example 31/03/2011 00:00:00
    Share on Google+

  5. #5
    Join Date
    Jun 2008
    Posts
    2,477

    Re: datetime - date only

    Well, the error seems pretty obvious

    "CS1501: No overload for method 'ToString' takes '1' arguments"
    Share on Google+

  6. #6
    Join Date
    Jul 2010
    Posts
    3

    Re: datetime - date only

    thanks BigEd781! if only i was as smart as you!.... why the hell would I ask for help if I knew what the error meant, I'm new to c# and don't know that's why I asking, just unfortunate that ****** like you are around! stop wasting my time and yours and show off somewhere else....I suspect you're only Big in name as well!
    Last edited by HanneSThEGreaT; July 23rd, 2010 at 06:24 AM. Reason: Removed Profanity.
    Share on Google+

  7. #7
    Join Date
    Jan 2010
    Posts
    1,099

    Re: datetime - date only

    Yo, easy with the bad blood!

    What Alsvha asked you is what is the type (class) of "Start", not what it represents.
    If it's the DateTime class, there should be an overload of the string method that would enable you to do what you wanted to do.

    As BigEd781 said, the error is pretty obvious - whatever the class of "Start" is, it doesn't contain such an overload. This indicates that it's not DateTime. Maybe you just stored the value in a string?

    Find in the definition of "Start" in your code, and find out the type.
    Share on Google+

  8. #8
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,074

    Exclamation Re: datetime - date only

    Quote Originally Posted by katy.morgan View Post
    thanks BigEd781! if only i was as smart as you!.... why the hell would I ask for help if I knew what the error meant, I'm new to c# and don't know that's why I asking, just unfortunate that ******* like you are around! stop wasting my time and yours and show off somewhere else....I suspect you're only Big in name as well!
    OK. That's quite inapropriate, and uncalled for. Calling people names will not get you anywhere here. This is the AUP

    I am closing this thread now, before it gets out of hand.

    Consider this a warning
    Share on Google+

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center