Results 1 to 3 of 3
  1. #1
    bayoeth is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2017
    Posts
    2

    How to Convert Date to "nth day of month, year"?

    hi guys,



    i'm new to this forum, and ms access.

    I was making a certificate and made a table where it has a field containing a date like mm/dd/yyyy.
    Then I made a form, but in that form I would like the date to appear as

    nth day of the month, year.

    For Example:
    If date is December 3, 2017, It would appear as "3rd day of December, 2017"

    I was trying to search the web, but i couldn't find any. Please help me. Thanks in advance.

  2. #2
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051

    How to Convert Date to "nth day of month, year"?

    Something like


    Code:
    Function datesentence (mydate as date) as string
    'assuming mydate is the date you are dealing with
    dim getmth as string
    dim getday as integer
    dim dateend as string
    Getmth = month(mydate)
    Getday =  DatePart("d",mydate)
    
    Select case as getday
    
    Case is = 1,21,31
    Dateend="st"
    
    Case is = 2,22
    Dateend ="nd"
    
    Case is = 3,23
    Dateend ="rd"
    
    Case else 
    Dateend = "th"
    
    End select
    
    datesentence = getday & dateend & "day of " & Getmonth

  3. #3
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,934
    or within a query you can use the format function

    FormattedDate: Format([myDate],"d""" & Switch(Day([myDate]) Mod 10=1,"st",Day([myDate]) Mod 10=2,"nd",Day([myDate]) Mod 10=3,"rd",True,"th") & " day of ""mmmm\,yyyy")

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

Similar Threads

  1. Replies: 5
    Last Post: 01-04-2017, 02:13 AM
  2. Replies: 3
    Last Post: 12-06-2014, 03:59 AM
  3. Replies: 4
    Last Post: 01-11-2014, 11:57 PM
  4. Replies: 2
    Last Post: 09-29-2012, 11:22 PM
  5. Is there such thing as "month and year as digit"
    By beejay101 in forum Queries
    Replies: 1
    Last Post: 05-16-2011, 11:28 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