access vba training - date formats functions
Microsoft Office TrainingThe UK's Number 1 for Microsoft Office Training Sitemap add this page to your favourites/bookmarksBookmark page
 
view a printable version of this pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

Forum home » Delegate support and help forum » Microsoft VBA Training and help » access vba training - Date formats in Functions

access vba training - Date formats in Functions

resolvedResolved · Low Priority · Version Standard

replyReplyWed 5 Dec 2007, 14:55Delegate James said...

Date formats in Functions

I am using the following excel formula in one of my cells:

="USD Balance as at "&DAY(TODAY()) & " " &MONTH(TODAY()) & " " &YEAR(TODAY())

Is it possible to create a function that will fill in the month in text form rather than number?

ie the above creates 5 12 2007 and I want it to show 5 December 2007

For upcoming training course dates see: Pricing & availability

replyReplyMon 10 Dec 2007, 12:51Trainer Carlos said...

RE: Date formats in Functions

Hi James

All you need to do is use the TEXT function on the Month's number value as seen in the reworked formula below. The use of "mmmm" produces the full month while "mmm" only produces the abreviation:

="USD Balance as at "&DAY(TODAY()) & " " & TEXT(MONTH(TODAY()),"mmmm") & " " &YEAR(TODAY())


Hope this helps

Carlos

replyReplyMon 10 Dec 2007, 14:19Delegate James said...

RE: Date formats in Functions

Hi Carlos,

I tried the above formula but it only seems to return "January" as the month value. This seems to be an excel bug as when I rewrote the formula as:

="USD Balance as at "&DAY(TODAY()) & " " & TEXT(MONTH(A1),"mmmm") & " " &YEAR(TODAY())

I tried several dates in A1 and the formula always returned the value "January"

Any ideas why?

James

replyReplyMon 10 Dec 2007, 14:58 Edited on Mon 10 Dec 2007, 14:59Trainer Carlos said...

RE: Date formats in Functions

James

Yes I have an idea. The TEXT function does not work as I presented it. I didn't notice the problem because I've been messing with my computer and had the date on Jan 2008.

I then checked some books and they all say there is no way of changing the months value to Text.

So I created a Function that takes the date you specify ie Totay() and by checking the Month value retrurns a month's name.

The code is:

Public Function MonthText(MyDate As Date) As String

Dim Monthvalue As Byte

MonthValue = Month(MyDate)

Select Case MonthValue

Case 1
MonthText = "January"

Case 2
MonthText = "February"

Case 3
MonthText = "March"

Case 4
MonthText = "April"

Case 5
MonthText = "May"

Case 6
MonthText = "June"

Case 7
MonthText = "July"

Case 8
MonthText = "August"

Case 9
MonthText = "September"

Case 10
MonthText = "October"

Case 11
MonthText = "November"

Case 12
MonthText = "December"

End Select

End Function


Then your formula would read

="USD Balance as at "&DAY(TODAY()) & " " & MonthText(TODAY()) & " " &YEAR(TODAY())


This should solve your problem

Carlos

replyReplyMon 10 Dec 2007, 15:28Delegate James said...

RE: Date formats in Functions

Thanks Carlos,

Trust Microsoft to make things difficult!!!

James

 

 

Vba tip:

Empty The Clipboard with CutCopyMode

After each Copy/Paste operation in VBA, you should use the following line of code to empty the clipboard. This ensures that the computer memory doesn't overload:

ActiveSheet.Paste
Application.CutCopyMode = False

View all VBA hints and tips

forum postHow do I add a logo to each page?

» Forum post: Slide Master


Rate this page:
2.2/5 (213 votes cast)
Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses
Microsoft Certified Partner
Security Seal verified by visa, mastercard securecard

Mini sitemap. These are the main areas of our web site. Full sitemap.

Management training

Professional Skills courses
Project Management Course London
Project Management Courses London
Project Management Training London
Project Management Training
Project Seminar
Project Seminars
Time Management Course London
Time Management London
Time Management Courses London
Time Management Training London
Introduction to Finance course
Assertiveness Skills course
Effective Communications Skills training
Presentation Skills London

Training Formats

Public scheduled courses
On-site training
Closed company courses

Consultancy
Application Development

Blogs

Excel Training
MS Project Training
Microsoft Training Blog

Version differences

Office 2010 vs 2007
MS Project version differences

Training Information

London Computer Training
Computer Training London
Docklands Training Courses
Docklands Training London

Training venues London
Client list
FAQ
Pricing and availability
Course details / Syllabus

Training Articles
Training Information

Microsoft training

Microsoft Office training
& IT Applications

Microsoft Project training
Microsoft Outlook training
Microsoft Powerpoint training
Microsoft Word training
MS Project courses
MS Project training
Outlook courses
PowerPoint courses
PowerPoint training
VBA courses
Word courses
Microsoft.training
(more...)

Excel Training

Excel courses
Excel Training Courses Medway
Autonumber in Excel
Microsoft Excel training
Basic Excel Courses
Basic Excel Course
Basic Excel Training

Interested in MS Access training?

Access courses
Microsoft Access training
Microsoft access courses
Microsoft training access course
Microsoft+access+training
Access courses in london

Training provider

Training providers
IT training companies
IT training providers
Management Training providers
Management Training provider

Event history, feedback results
Events in 2012 · 2011 · 2010 · More

See also

Crystal Reports training