473,385 Members | 1,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

I have a problem running Format in A97

MLH
If I run this...
For i = -1 To -12 Step -1
Debug.Print CStr(Month(DateAdd("m", i, Now))) & "/";
CStr(Year(DateAdd("m", i, Now)))
Next i

I get this...
5/2005
4/2005
3/2005
2/2005
1/2005
12/2004
11/2004
10/2004
9/2004
8/2004
7/2004
6/2004

which is exactly what I want, except for one thing -
I would like to see month abbrev replace the numbers.
So, I run this...

For i = -1 To -12 Step -1
Debug.Print Format(Month(DateAdd("m", i, Now)), "mmm") & "/";
CStr(Year(DateAdd("m", i, Now)))
Next i
But, unfortunately, it returns this...
Jan/2005
Jan/2005
Jan/2005
Jan/2005
Dec/2005
Jan/2004
Jan/2004
Jan/2004
Jan/2004
Jan/2004
Jan/2004
Jan/2004

Am I missing something here?
Nov 13 '05 #1
2 1213
"MLH" <CR**@NorthState.net> wrote in message
news:di********************************@4ax.com...
[snip]
I would like to see month abbrev replace the numbers.
So, I run this...

For i = -1 To -12 Step -1
Debug.Print Format(Month(DateAdd("m", i, Now)), "mmm") & "/";
CStr(Year(DateAdd("m", i, Now)))
Next i
But, unfortunately, it returns this...
Jan/2005
Jan/2005
Jan/2005
Jan/2005
Dec/2005
Jan/2004
Jan/2004
Jan/2004
Jan/2004
Jan/2004
Jan/2004
Jan/2004

Am I missing something here?


Yes, the expression...

Format(Month(DateAdd("m", i, Now)), "mmm")

....is incorrect because to format something as "mmm" you must provide a first
argument that is a date and the Month() function returns an integer. Since
dates are actually Doubles under the covers you are actually asking to format a
date that occurs in the first 12 days of the year 1900. Just remove the Month()
function from your expression and it should work.

Actually all you need is...

Format(DateAdd("m", i, Now), "mmm/yyyy")

--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com


Nov 13 '05 #2
MLH
Many thx, Rick. That was certainly my problem.
Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Bas de Laat | last post by:
I'm trying to fix a running (12 month rolling) sum on a large table (over 50.000) record. I found already several good advices. First I Tried it with an Subquery But for large tables it takes to...
9
by: turtle | last post by:
I need my running sum to work for more than one year. It works great but then starts over when the year starts over. My example here is straight from the Northwind database. I want a runningg sum...
1
by: Trygve Lorentzen | last post by:
Hi, my webservice is running on Win2000 SP4, IIS 5.0 fully patched, connecting to a MySQL database and mainly returning Typed DataSet's from webmethods. After running for a while, generally a...
8
by: TS | last post by:
Hi, i have inherited a page from another user. The page is the target frame in a frameset. for some reason the whole page runs twice (page_load, init, etc. all run twice) I can't figure out how...
1
by: rajesh | last post by:
var fixedX = -1 // x position (-1 if to appear below control) var fixedY = -1 // y position (-1 if to appear below control) var startAt = 0 // 0 - sunday ; 1 - monday var showWeekNumber =...
1
by: ship | last post by:
Hi How do we open up an MS Access ".mdb" file (from Office 2000 format I think), WITHOUT the macros running?! Our MS Access guy is on holiday for 2 weeks. Most of the office is on Office...
1
by: PlayQ | last post by:
I am using the WMEncoder (seris 9) object inside a .net(c#) encoding app that encodes a wave file to a wma file. Everytime I create and use the WMEncoder object it leak system handles even after I...
1
by: Vikas | last post by:
Hi all, I am working on a document control database where I have a table "tblControl" containing two columns "DocID" and "SchIssueDate". "DocID" is the key field with text format while...
3
by: Phil Stanton | last post by:
I have a number of queries which use code for the output of 1 or more fields. For example Address:GetAddress(AddressID, True, 60) Address ID Points to an Address in a table - Address Line1, Line...
9
by: JJM0926 | last post by:
I'm trying to create a running totals query in access 97. I have followed the directions on how to do it from Microsofts website article id 138911. I took their code they had and replaced it with...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.