Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date question

Status
Not open for further replies.

tfstom

Programmer
Sep 28, 2002
190
US
I am trying get the day of the week from some text that is passed to me.

I know I can get the Numeric day of week (1 - 7) by doing Weekday("03/15/2004"), but the dates I am getting are from the airlines and are in format 15mar04 (ddmmmyy). I need to get the day of the week (Sun,Mon etc).

How would I best do this in ASP?

Thanks,

Tom.
 
You will probably have to set up a function to convert the date first and then get the day name

function convertDate(inDate)

Dim dayNum : dayNum = Left(inDate, 2)
Dim mth : mth = Mid(inDate, 3, 3)
Dim yrNum : yrNum = Right(inDate, 2)

convertDate = CDate(dayNum & "-" & mth & "-" & yrNum)

end function

Then in the main body of your code call the function.

myDate = "15mar04"
dayName = WeekDayName(WeekDay(convertDate(myDate)), true)

This should work I think.


Mighty
 
That worked great.

I put it in an include file, since I will be using it all over.

I was very irritated to see that there was a WeekDayName function out there and none of the 3 books I have on ASP mention this function. One of the biggest problems with most of the languages is dealing with Dates, yet I can find only sparse information on this (and as I mentioned nothing on WeekDayName).

I am glad to find it. I am sure that there are other functions that would help me that are not documented in the books I have. What a pain.

Thanks,

Tom.
 
O'Reilly's little "VBScript Pocket Reference" is super-handy for looking up stuff like that. Very quick and easy to use, only a 100 or so paperback-sized pages.
 
I'll have to check that one out.

Thanks,

Tom.
 
I have a great little help file type application that I downloaded from the web which is basically Windows Script Host documentation. As far as I remember, I just downloaded it from the Microsoft site. This has every VBScript command that you can think of and the good thing about it is that when you search for one command it gives links to all related commands at the bottom of the page.

If you want to search on the Microsoft site I'm sure that you will find it. If not, post your email address and I will send you on the Self-Extracting Executable to install.

Mighty
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top