Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    CP611 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Nov 2017
    Posts
    55

    Converting Date Type

    Hello,

    I am looking to run a query that will change a date from one format into another. The current format is Jan 9, 2024. Whereas I would want it to show 09/01/2024. I have used the below query in the past the transfer it from another format into the one I am after so this is the sort of thing I would need again

    Format(CDate(Replace(Left([Submission Date],InStr([Submission Date]," ")-1),":","/")),"dd/mm/yyyy")

    Thank you

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    =DateAdd("d",-1,[[submission date])

  3. #3
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2019
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Quote Originally Posted by ranman256 View Post
    =DateAdd("d",-1,[[submission date])
    Should that be:
    DateAdd("d",0,[submission date])
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,943
    Code:
    tt=#Jan, 9 2024#
    ? tt
    09/01/2024
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #5
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    Dates are stored as numbers so all you need to do is set the format property of whatever control is displaying the value, no need for a query

    or are you saying your date field is actually a string?

  6. #6
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,803
    To add to all that, there is no point in wrapping CDate inside of Format because format will change it back to a string, so one might as well just work with a string?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    CP611 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Nov 2017
    Posts
    55
    Quote Originally Posted by Bob Fitz View Post
    Should that be:
    DateAdd("d",0,[submission date])
    this worked, thank you!

  8. #8
    CP611 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Nov 2017
    Posts
    55
    I have another one where the date is showing as 09/01/2024 13:02:00 but I want it to just show as 09/01/2024. Even if I change it to short date on the excel spreadsheet before putting it in it still keeping the time in as 00:00:00 which I want to get rid of. What could the query be to change it to the correct format?

  9. #9
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,943
    Use Datevalue()

    A format is just that a *format*. The cell will still have a time element in it.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  10. #10
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2019
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Quote Originally Posted by CP611 View Post
    I have another one where the date is showing as 09/01/2024 13:02:00 but I want it to just show as 09/01/2024. Even if I change it to short date on the excel spreadsheet before putting it in it still keeping the time in as 00:00:00 which I want to get rid of. What could the query be to change it to the correct format?
    Perhaps:
    DateAdd("d",0,Left([submission date],8))
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  11. #11
    CP611 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Nov 2017
    Posts
    55
    Hi there, unfortuantely that one didn't work it just converted it into a blank field

  12. #12
    Join Date
    Apr 2017
    Posts
    1,681
    To remove time part try Int([submission date])
    (Must work when your 'date' is really a Date!)

  13. #13
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,943
    Quote Originally Posted by CP611 View Post
    Hi there, unfortuantely that one didn't work it just converted it into a blank field
    Who are you replying to?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  14. #14
    CP611 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Nov 2017
    Posts
    55
    hi there, thank you for the advice so far! sadly none of the options have worked so far, it still turns it into a blank field

  15. #15
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,943
    So it is not a date type?
    Use CDate() in that case.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 04-23-2018, 05:48 AM
  2. Replies: 2
    Last Post: 10-30-2017, 02:33 PM
  3. Replies: 7
    Last Post: 12-26-2014, 12:17 PM
  4. Converting text to number type
    By togo in forum Access
    Replies: 12
    Last Post: 09-18-2012, 12:59 PM
  5. Converting TableData Type
    By TimMoffy in forum Access
    Replies: 5
    Last Post: 06-19-2012, 09:10 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