Retrieve date from database

Discussion in 'Microsoft VB .NET' started by michele, Aug 4, 2006.

  1. michele

    michele Guest

    Hi, I want to load a listbox with the date that are stored in a database
    (mdb), the problem is when I retrieve the date it has a format like
    "01/01/2006 0.00.00". In Access the date is stored as short date.
    Thanks in advice
     
    michele, Aug 4, 2006
    #1
    1. Advertisements

  2. michele

    Jerry H. Guest

    Try this:

    dim dtDate as date
    dtDate = format(Cdate([AccessDateField]), "MM/dd/yyyy hh.mm.ss")

    I'm not 100% sure about this, but even though Access date fields
    display as shortdate, I believe the stored value also contains the
    Time, and if that is the case, the above code will display what you
    need. But if only the Date is stored then the Time stamp portion will
    likely return only "12.00.00"

    Good luck!


    michele wrote:
    > Hi, I want to load a listbox with the date that are stored in a database
    > (mdb), the problem is when I retrieve the date it has a format like
    > "01/01/2006 0.00.00". In Access the date is stored as short date.
    > Thanks in advice
     
    Jerry H., Aug 4, 2006
    #2
    1. Advertisements

  3. michele

    michele Guest

    I try it and it works fine, thanks


    "Jerry H." <> ha scritto nel messaggio
    news:...
    > Try this:
    >
    > dim dtDate as date
    > dtDate = format(Cdate([AccessDateField]), "MM/dd/yyyy hh.mm.ss")
    >
    > I'm not 100% sure about this, but even though Access date fields
    > display as shortdate, I believe the stored value also contains the
    > Time, and if that is the case, the above code will display what you
    > need. But if only the Date is stored then the Time stamp portion will
    > likely return only "12.00.00"
    >
    > Good luck!
    >
    >
    > michele wrote:
    >> Hi, I want to load a listbox with the date that are stored in a database
    >> (mdb), the problem is when I retrieve the date it has a format like
    >> "01/01/2006 0.00.00". In Access the date is stored as short date.
    >> Thanks in advice

    >
     
    michele, Aug 7, 2006
    #3
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Adam

    BLOB Retrieve and Display problems

    Adam, Jul 3, 2003, in forum: Microsoft VB .NET
    Replies:
    2
    Views:
    631
  2. Mark Kloch

    Retrieve database id?

    Mark Kloch, Jan 4, 2004, in forum: Microsoft VB .NET
    Replies:
    3
    Views:
    177
  3. Guest
    Replies:
    19
    Views:
    323
    Guest
    May 1, 2004
  4. Neil
    Replies:
    1
    Views:
    212
    Ken Tucker [MVP]
    May 5, 2004
  5. tranky
    Replies:
    2
    Views:
    270
    Ken Tucker [MVP]
    Aug 10, 2005
Loading...

Share This Page