Results 1 to 8 of 8
  1. #1
    JonathanT is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2011
    Posts
    118

    Convert Short Date filed to a String


    I have a Short Date field on a form connected to a table. I want to convert that field to a string and store that in a different field in the table. In other words if 1/1/2023 is my Short Date field I want to convert that to January and store that value in another field in the table. I want to be able to query the table based on a month. Is this possible?

  2. #2
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    You don't need to store it in another field. In your query add a calculated field MyMonth:Month([YourDateField]) and in its criteria row put 1 (for January). Or you could use the MyMonth:MonthName(Month([YourDateField])) if you want to return the actual month names instead of their numbers. Or look into the Format() function if you need month and year or any other formats.
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,428
    @jonathanT - are you aware that dates are stored as a double data type? The format you see for short date is just that. A format based on your local settings. The underlying value stores date and time,the number before the decimal point is the number of days since 31/12/1899 and the value after is the number of seconds to now divided by the number of seconds in a day (86400)

    So if you want to see a month name format as long date - mmmm dd yyyy (assuming us format and see January) or you might use dd mmm yyyy if you wanted UK format and see Jan.

    To search for a month use Gifu’s suggestion

  4. #4
    JonathanT is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2011
    Posts
    118
    Thanks for the replies. I was able to calculate the Month and Year in my query using the example provided by Gicu. I have been unable to also calculate the Quarter using the same configuration . Is that possible?

  5. #5
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,428
    use the datepart function
    https://learn.microsoft.com/en-us/of...epart-function


    or calculate from month - ((month(mydate)-1)/3)+1 - note the direction of \
    ?((1-1)\3)+1
    1
    ?((2-1)\3)+1
    1
    ?((3-1)\3)+1
    1
    ?((4-1)\3)+1
    2
    ?((12-1)\3)+1
    4

  6. #6
    JonathanT is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2011
    Posts
    118
    Thanks for the replies. I was able to calculate the Month and Year in my query using the example provided by Gicu. I have been unable to also calculate the Quarter using the same configuration . Is that possible?

  7. #7
    JonathanT is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2011
    Posts
    118
    I was able to solve my quarter issue by using the following calculated field. ReportQuarter: Format([currdate],"q")

  8. #8
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,428
    just be aware that the value created using the format function is text - since the range can only be 1-4 it wont impact sorting, but you will need to use quotation delimiters if using as a criteria or filter

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

Similar Threads

  1. Convert date from short date to general date
    By cebrower in forum Access
    Replies: 4
    Last Post: 04-24-2019, 08:08 AM
  2. Convert String to Date
    By swenger in forum Access
    Replies: 2
    Last Post: 01-31-2017, 03:03 PM
  3. Convert Short text column to date ms access
    By SameerSarswat in forum Access
    Replies: 3
    Last Post: 10-09-2014, 10:42 AM
  4. How to convert Date to String?
    By thebaul in forum Access
    Replies: 1
    Last Post: 08-01-2012, 05:51 AM
  5. Convert string to date
    By ~SwAmPdOnKeY~ in forum Queries
    Replies: 4
    Last Post: 09-11-2008, 07:19 PM

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