CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Dates

  1. #1
    Join Date
    Jul 2000
    Location
    Cambridge, England
    Posts
    40

    Dates

    Hi,

    We've written an app that makes use of the DateValue() function. Specifically I create dates like this:

    myDate = DateValue( dd & "/" & mm & "/" & yy )



    where dd is the day number, mm the month number and yy the year. This worked fine on our own machines. When we tried this on a brand new machine we got an error. Looking at the documentation it says that DateValue creates the dates based on the short date format as set up on the local machine. The new machines were preconfigured with American standard dates (ie mm/dd/yy) and hence when I tried to set the date to be 31st July 2000 as 31/07/2000 I got an error.
    Is there any way to get around this problem and force the system to recognise that I want to view all dates as dd/mm/yyyy ?
    TIA
    Welly


  2. #2
    Join Date
    Jan 2000
    Location
    MO, USA
    Posts
    1,506

    Re: Dates

    if you are only displaying dates in this format, why not use the Format function:

    txtDate.Text = Format(date,"dd/mm/yyyy")




    the date can be in any format in the database, or source file, but when you want to display it - just format like so.

    if you need to create a date - create a date as you normally would, then when it comes time to show it, use the format function.

    hope this helps,

    John

    John Pirkey
    MCSD
    http://www.ShallowWaterSystems.com
    http://www.stlvbug.org
    John Pirkey
    MCSD (VB6)
    http://www.stlvbug.org

  3. #3
    Join Date
    Jul 2000
    Location
    Cambridge, England
    Posts
    40

    Re: Dates

    Thanks but it doesn't help! I am actually creating dates from the raw components of day,month & year. What I think I need to know is what is the system short date format - that way I can then create dates safely.


  4. #4
    Join Date
    May 1999
    Posts
    3,332

    Re: Dates

    the GetDateFormat API might be helpful.


  5. #5
    Join Date
    Jul 2000
    Location
    Cambridge, England
    Posts
    40

    Re: Dates

    Thanks - I'll have a look into that.


Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured