I mostly write macros in word using VBA. A user
needs to enter a date like this one: 070797 and I need it to look like this:
July 07, 1997 on the document. Can you help? Also, are there other ways of
formatting dates? I've tried putting the date in a variable and doing
something like this:
myDate = DTPicker1.value
format(myDate, "mmm, & " " & mid(3, 2 ) & ", " & right(2))
But, this didn't work.

Format(Date(),"mmmm dd"", ""yyyy")

Paladine,
thanks for your reply, but it still didn't work for me.
Example: A user enters 020161 (my birthday).
I format it using: Format(birthday,"mmmm dd"", ""yyyy")
I actually get 20161. I want to get: February 1, 1961.

Thanks!

Paladine,
here's a good example of what I am talking about. I have a book called Visual Basic .Net How to Program (2nd edition). It has many good problems and examples, but no answers to see if what you are doing is correct. This is one of the problems:

Create a CDateFormat class with the following capabilities:

a) Ouptut the date inmultiple format such as

MM/DD/YYYY
June 14, 2001
DDD YYYY

b) Use overloaded constructors to create CDateFormat objects initialized with dates of the formats in part a.

I cannot get any of the formats to work. I even used the format previously suggested by you, Paladine. What am I doing wrong?

You say the book has problems without answers? Is it possibly meant to be used as a student's textbook? If you really like the book, perhaps you can check the publisher's website to see if there is an "answer key" softcover available?

Hi and thanks for the suggestion. I will look for an asnwer key on their web site. I guess this book can be used as a textbook, but I wouldn't use it if I had to teach a class. The only reason I am looking at it is because my company is going to vb.net and a friend let me have the book before she moved to Alabama. It was a brand new book (she never even looked at it). Anyway, it is teaching me some vb.net stuff, but if I get stuck with a problem I am out of luck because there are no answers. I am also reading a VB.Net Step-by-Step book. It is pretty good for a beginner like me.

OK, I am little confused, are you doing this Date time thing in VBA or VB.NET? you started the thread with VBA?

Just want to clarify

I just re-read the thread, and I have to ask more details on the .NET question. Because, it will invariably depend on how the data is entered. There are numerous combinations. Jul 20,03 Jul 20/03, 07/20/03, 072003, 20/07,03 ... get my meaning. There is no way, that I have come across that in code you can compensate for those variations.

Now,using VBA, the Format function I gave you, it will work for almost and combination that uses divisions between date characteristics. i.e. spaces, commas, slashes. but as consecutive numbers, I am sorry to say it doesn't.

Anyone else have any ideas?

Hi Paladine.

you are correct, I did confuse the issue a bit. I mostly do macros at work using VBA, and I just tried your suggestion on that and it works. My other question is for VB.NET. I was given a book (book called Visual Basic .Net How to Program, 2nd edition),and I am trying to do the problems:

Create a CDateFormat class with the following capabilities:

a) Ouptut the date inmultiple format such as

MM/DD/YYYY
June 14, 2001
DDD YYYY

b) Use overloaded constructors to create CDateFormat objects initialized with dates of the formats in part a.

BUT, I cannot get anything to work. Any ideas?

Ok I_Byte. Do something like, have the user provide a date, in any date format they choose, and you can use the ToString() Function to output the result to any date format you like.

Example:

User passes in a date like 22/07/03, but you want it to be in as Tuesday, July 22, 2003
{ this is pseudo-code}


Ok, well

Dim dbdate As String = <some value passed in from user input>
            Dim newdate As DateTime = Convert.ToDateTime&#40;dbdate&#41;
            MsgBox&#40;"newdate.ToString&#40;"D"&#41;&#41;

Hope that helps. There are several ways to do it, but ultimately it is up to you.

As far as the constructors are concerned, I will leave you play with that one.

Are you using VB.NET learning edition or just command line stuff or VS.NET?

Opps. forgot to mention something. Sorry been working every night this week. The "D" in the ToString function, is one of several preset strings in VB.NET for date time formats. "d" is the classic 22/07/03 for example.

my bad...

Thanks for all your help. As I said before, I am mostly doing stuff in VBA at work, but I was told to learn VB.NET since we might be goint to it soon. There is only one computer at work that has VB.NET on it. A friend gave me a book and I am trying to follow it. I would not have purchased it myself because it really isn't that good. I borrowed a STEP-BY-STEP book from a co-worker that is being more helpful. I am glad I found this forum! I have a feeling I will be using it a lot. So, can you tell me what you do besides post responses on this forum? :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.