#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2008
    Posts
    3
    Rep Power
    0

    Problem in displaying current date using label


    hai guys..

    i'm having prob regarding displaying current date using label..
    i'm using this code:

    lblCurrTime.Text = Format$(Now, "dd mm yy")

    the output is:

    14 32 08

    14 is day
    32 is month..why is this happen?
    08 is year..

    plz help me..
  2. #2
  3. Type Cast Exception
    Devshed Supreme Being (6500+ posts)

    Join Date
    Apr 2004
    Location
    OAKLAND CA | Adam's Point (Fairyland)
    Posts
    14,954
    Rep Power
    8617
    Not for me

    Code:
    ? Format$(Now, "dd mm yy")
    13 03 08
    Sounds like regional settings. Country and platform. ... ??

    Thought:

    Code:
    ? format(now,"hh mm ss")
    12 00 36
    Ambiguous it can be minutes...

    Maybe try using Date instead of Now. Also you can get rid of $ in VB now BASIC artifacts are long gone...

    Code:
    ? format(Date,"dd mm yy")
    13 03 08
    Last edited by medialint; March 13th, 2008 at 02:02 PM.
    medialint.com

    “Today you are You, that is truer than true. There is no one alive who is Youer than You.” - Dr. Seuss
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2008
    Posts
    3
    Rep Power
    0
    i've tried using both of ur code..
    but it still produce the same error.

    may u rite..
    may be i need to adjust something in regional settings
    but what is it..i dunno..
  6. #4
  7. Arcane Scribbler
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jun 2005
    Location
    Indianapolis, IN
    Posts
    1,907
    Rep Power
    585
    I can't think of any regional settings that would make month come out as 32.

    In VB6, mm is month and nn is minutes. In VB.NET MM is month and mm is minutes.

    What do the following 2 formats output to your label?
    [code=VB6]Format$(CDate("2001-02-03 04:05:06"), "yyyy-mm-dd hh:nn:ss")
    Format$(CDate("2001-02-03 04:05:06"), "dd mm yy")[/code]

    Comments on this post

    • zynder agrees
    Joel B Fant
    "An element of conflict in any discussion is a very good thing. Shows everybody's taking part, nobody left out. I like that."

    .NET Must-Haves
    Tools: Reflector
    References: Threading in .NET
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2008
    Posts
    3
    Rep Power
    0
    Originally Posted by LyonHaert
    I can't think of any regional settings that would make month come out as 32.

    In VB6, mm is month and nn is minutes. In VB.NET MM is month and mm is minutes.

    What do the following 2 formats output to your label?
    [code=VB6]Format$(CDate("2001-02-03 04:05:06"), "yyyy-mm-dd hh:nn:ss")
    Format$(CDate("2001-02-03 04:05:06"), "dd mm yy")[/code]
    LyonHaert..
    u just solved my prob..
    thanx so much..

    i only changed mm to MM..n it displayed 14-03-8

    thanx againnn!!
  10. #6
  11. Arcane Scribbler
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jun 2005
    Location
    Indianapolis, IN
    Posts
    1,907
    Rep Power
    585
    I should have noticed you were setting a Text property on the Label. Definitely .NET. (In VB6, it would have been a Caption property.)
    Joel B Fant
    "An element of conflict in any discussion is a very good thing. Shows everybody's taking part, nobody left out. I like that."

    .NET Must-Haves
    Tools: Reflector
    References: Threading in .NET

IMN logo majestic logo threadwatch logo seochat tools logo