Results 1 to 3 of 3

Thread: Date proble,

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 1999
    Karachi, Sind, Pakistan


    Hi there,
    I am facing a problem while using Visual Basic version 6, Service Pack 3.
    My database is in MS Access and when I try to store date in the date field
    of the database, I get the the conversion problem while diplaying date in
    the Mask Edit field on the form; date displays in the format that
    is set in the regional settings of the Windows Control Panel. Can you help
    me in displaying the date field irrespective of the regional settings
    in dd/mm/yyyy format?

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Mashin' on the motorway
    Why not set the Regional Settings up properly? The idea of displaying the date is that it is in the local format.

    In Access, I think there's a way to change the date format, will clarify in a few moments...
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    off others' brains

    Well ...

    I had exactly the same problem when I tried to replace all textboxes on my form with the Masked Edit box. Actually you can try a number of ways here:

    1. Retrieve the date from the Access database, use the VB Format() function to format it into 'dd/mm/yyyy' and show it.

    2. Retrieve the date from the Access database in such a way that it is already formatted in 'dd/mm/yyyy' format, using SQL date conversion functions (of which, sadly I am not an expert.)

    There is a third solution of using the Mask property of the editbox control, but I am not too sure whether it supports dd/mm/yyyy. If it does, you can assign the date value to the box, and then set the Mask property. Or if you have already set the Mask property, use a temporary variable and write the code as follows:

    Dim tmpMask As String
    Dim dbDate As Date
    '  Open recordset etc. etc.
    '  Fetch the date value into the dbDate variable
    tmpMask = MaskEditBox1.Mask
    MaskEditBox1.Mask = ""
    MaskEditBox1.Text = dbDate
    MaskEditBox1.Mask = tmpMask

    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

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