Results 1 to 12 of 12
  1. #1
    dollygg is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jul 2009
    Posts
    73

    date


    The date is showing as "12:02:23 AM" in th backend table. I set the default value =Format(DateSerial(Year(Date()),Month(Date()),0)," dd/mm/yyyy") and the format = short date. Once that table get exported excel by running the VBA code , the date is showing as "00/01/1900 12:02:23 AM" . I am running a MDB file. Why is not working?

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Is the field in the BE a date/time type field?

    I would use
    default value = DateSerial(Year(Date()),Month(Date()),0)

    What does the data in the field look like in the BE?

    The FORMAT command is how the value is displayed.

    It is possible that the export is the wrong field/incorrect/changing the date field.
    How is the export being performed?

  3. #3
    dollygg is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jul 2009
    Posts
    73
    Yes, it's a date field.
    It is showing as a time in the BE table. Therefore the export have problem.
    if I run the query manually in Access , then the date is showing correctly . If I run the same query by code , then it's not.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,643
    The Format() function returns a text value, so try dropping that and just using the DateSerial() function.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    dollygg is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jul 2009
    Posts
    73
    I did that already but didn't work. The problem is on VBA. I am getting two different result by running the same query manually or by the macro.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,643
    What's the VBA code?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    dollygg is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jul 2009
    Posts
    73
    Docmd.runquery ("name if the query")

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,643
    A query will not export to Excel by itself. Can you post the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    dollygg is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jul 2009
    Posts
    73
    Quote Originally Posted by pbaldy View Post
    A query will not export to Excel by itself. Can you post the db here?
    I have another piece of code to export to excel. However the problem occur before the export
    . The order is , run the query to update the table, then export to excel. However the date field is showing a time in the table before the export.
    I don't mind uploading the code or db tomorrow.

  10. #10
    dollygg is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jul 2009
    Posts
    73
    Quote Originally Posted by dollygg View Post
    I have another piece of code to export to excel. However the problem occur before the export
    . The order is , run the query to update the table, then export to excel. However the date field is showing a time in the table before the export.
    I don't mind uploading the code or db tomorrow.
    Never mind, I find another way to get around this problem. What I did is , write the excel vba code to change the date on the excel file.

  11. #11
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    OK, ready to mark this solved?

  12. #12
    dollygg is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jul 2009
    Posts
    73
    Quote Originally Posted by ssanfu View Post
    OK, ready to mark this solved?
    Yes, Please!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 07-09-2013, 06:31 PM
  2. Replies: 1
    Last Post: 02-12-2013, 03:48 AM
  3. Replies: 5
    Last Post: 12-18-2012, 02:37 PM
  4. Replies: 3
    Last Post: 08-21-2012, 03:05 PM
  5. Replies: 15
    Last Post: 04-06-2012, 10:57 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums