BigJobbies
BigJobbies

Reputation: 4045

Classic ASP - format date

I have a date being extracted from the database which is formatted as following

12/23/2005

Which is

mm/dd/yyyy

I want to convert it in classic asp to the following

December 23 2004

Could anyone help me with this?

Cheers,

Upvotes: 1

Views: 12207

Answers (2)

MazepiC
MazepiC

Reputation: 335

You could try this:

Function FormatDate(input)
    FormatDate = MonthName(Month(CDate(input))) & " " & Day(CDate(input)) & " " & Year(CDate(input))
End Function
Response.Write(FormatDate("12/23/2005"))

I'm assuming you want it to show "December 23 2005" if you want it to show "December 23 2004" then just subtract one from the Year() call:

FormatDate = MonthName(Month(CDate(input))) & " " & Day(CDate(input)) & " " & (Year(CDate(input))-1)

Upvotes: 7

morishuz
morishuz

Reputation: 2402

assuming you are doing this in c#

DateTime thisDate = new DateTime.Now;
String outString = thisDate.ToString("MMMM dd, yyyy");

Upvotes: -3

Related Questions