By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,495 Members | 994 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,495 IT Pros & Developers. It's quick & easy.

How to convert date in words?

P: 1
I want to convert date like 1-1-2011 covert "First January, Two thousand eleven". What is code for module in Access?
May 19 '12 #1
Share this Question
Share on Google+
2 Replies


100+
P: 759
A possible solution:

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Sub Test()
  5. Dim TestDate As Date
  6.     TestDate = CDate("11.04.2013")
  7. Dim dtString As String
  8.     dtString = DateInWords(TestDate)
  9.  
  10.     MsgBox (dtString)
  11. End Sub
  12.  
  13. Function DateInWords(dt As Date) As String
  14. Dim strDays As String, SplitDays
  15.     strDays = "Day_1,Day_2,Day_3,Day_4,Day_5,Day_6,Day_7,Day_8,Day_9,Day_10,Day_11,Day_12,Day_13,Day_14,Day_15,Day_16,Day_17,Day_18,Day_19,Day_20,Day_21,Day_22,Day_23,Day_24,Day_25,Day_26,Day_27,Day_28,Day_29,Day_30,Day_31"
  16.     SplitDays = Split(strDays, ",")
  17. Dim strMothes As String, SplitMonthes
  18.     strMothes = "Month_1,Month_2,Month_3,Month_4,Month_5,Month_6,Month_7,Month_8,Month_9,Month_10,Month_11,Month_12"
  19.     SplitMonthes = Split(strMothes, ",")
  20. Dim strYears As String, SplitYears
  21.     strYears = "Year_2010,Year_2011,Year_2012,Year_2013,Year_2014,Year_2015,Year_2016,Year_2017,Year_2018,Year_2019,Year_2020"
  22.     SplitYears = Split(strYears, ",")
  23.  
  24. Dim strDay As String
  25.     strDay = SplitDays(Day(dt) - 1)
  26. Dim strMonth As String
  27.     strMonth = SplitMonthes(Month(dt) - 1)
  28. Dim strYear As String
  29.     strYear = SplitYears(Year(dt) - 2010)
  30.  
  31.     DateInWords = strDay & " " & strMonth & ", " & strYear
  32. End Function
May 19 '12 #2

NeoPa
Expert Mod 15k+
P: 31,186
Expand|Select|Wrap|Line Numbers
  1. Format({DateValue},"d mmmm, yyyy")
This doesn't handle ordinals (First, second, etc), but simply shows the number instead.
May 19 '12 #3

Post your reply

Sign in to post your reply or Sign up for a free account.