Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Senior Coder
    Join Date
    Aug 2002
    Location
    A 4D universe
    Posts
    1,337
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Displaying dates using TLabel in C+Builder.

    Anyone know how to display the day of the week in a label component?


    Cheers.


    Ionsurge.
    http://www.mudsplat.com - Web design, print, and marketing solutions.

  • #2
    New Coder
    Join Date
    Oct 2002
    Location
    Atlanta
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Syntax should be similar to Delphi, since they both share the VCL, so I'm guessing it's something along the lines of

    TLabel lblDate;

    lblDate.caption = DateTimeToStr( Now() );

    I realize that C++ is case sensative, so I leave it up to you to figure that much of it out.

    Hope that helped ...


  • #3
    Senior Coder
    Join Date
    Aug 2002
    Location
    A 4D universe
    Posts
    1,337
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I will try that out later today, thanx for that.


    Ionsurge.
    http://www.mudsplat.com - Web design, print, and marketing solutions.

  • #4
    Senior Coder
    Join Date
    Aug 2002
    Location
    A 4D universe
    Posts
    1,337
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanx, but that is not exactly what I was looking for, it works in that it displays the date, e.g. 04/11/02. I was looking for something that would show the date as 'Monday 4 November 2002'

    All I had to do with the code was:

    before:

    lblDate.caption = DateTimeToStr( Now() );

    after:

    lblDate->Caption = DateTimeToStr( Now() );


    Ionsurge.
    http://www.mudsplat.com - Web design, print, and marketing solutions.

  • #5
    New Coder
    Join Date
    Oct 2002
    Location
    Atlanta
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Since I do not have access to the Delphi help files at the moment, I can only suggest the following ...

    In the C++ Builder help file system, look up Date Formats pertaining to Long/Short date formats.

    Also look for DayOfWeek functions; or search on the Now() function and check out what they have listed under "Also see".


    If you are in need of the help files, they can be downloaded from Borland's website. They are about 11mb.

    Good-luck,
    D.

  • #6
    Senior Coder
    Join Date
    Aug 2002
    Location
    A 4D universe
    Posts
    1,337
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I got the help files with the C++Builder CD, and the DayOfTheWeek thing is pretty good. I cant believe that I have been stressing over it for so long and it was just there. If I have any probs, I will let you know.


    Cheers.



    Ionsurge.
    http://www.mudsplat.com - Web design, print, and marketing solutions.

  • #7
    Senior Coder
    Join Date
    Aug 2002
    Location
    A 4D universe
    Posts
    1,337
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Wohoo, thanx mate, I got it to work. I had to re-write some of the code, and add a bit of my own.

    The code would look something like this:


    StatusBar1->Panels->Items[3]->Text = DateToStr(Date());
    char days[7][10] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };
    TDateTime dtDate = StatusBar1->Panels->Items[3]->Text;
    StatusBar1->Panels->Items[3]->Text = days[dtDate.DayOfWeek() -1];
    I used a similar thing to make it show the day, and year on the status bar.

    It is in C++, so it may look a bit strange to some of you all.



    Ionsurge.
    http://www.mudsplat.com - Web design, print, and marketing solutions.


  •  

    Posting Permissions

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