PDA

View Full Version : Past Years Day Of The Week


JoeP
09-08-2002, 04:14 AM
The Code at the bottom of this post is a clean little Javascript that gives me the Day/Date. (e.g the output is "Sat, Sep 7, 2002" )

I would appreciate an ASP script that would give me the same thing with available variables coming from an ASP SELECT statement.

intMonth
intDay
intYear


I am attempting to give The ACTUAL Day of The Week for my Signature Script (see Signature Below) selection "Today's Events In History" for the curDate and curYear comment for each event. (e.g. "Sat, Sep 7, 1932") where intYear = 1932.

Any tips / suggestions will be appreciated.

Thank You.


<script language = "JavaScript">
<!--
curDate = new Date();
var curDay = "";
curMonth = new Array(12);
curMonth[0] = "Jan";
curMonth[1] = "Feb";
curMonth[2] = "Mar";
curMonth[3] = "Apr";
curMonth[4] = "May";
curMonth[5] = "Jun";
curMonth[6] = "Jul";
curMonth[7] = "Aug";
curMonth[8] = "Sep";
curMonth[9] = "Oct";
curMonth[10] = "Nov";
curMonth[11] = "Dec";

if(curDate.getDay() == 1){curDay = "Mon";}
if(curDate.getDay() == 2){curDay = "Tue";}
if(curDate.getDay() == 3){curDay = "Wed";}
if(curDate.getDay() == 4){curDay = "Thu";}
if(curDate.getDay() == 5){curDay = "Fri";}
if(curDate.getDay() == 6){curDay = "Sat";}
if(curDate.getDay() == 7){curDay = "Sun";}
if(curDate.getDay() == 0){curDay = "Sun";}

var curYear = curDate.getYear();
var BrowserName = navigator.appName;

if(BrowserName == "Netscape"){var curYear = curDate.getYear() + 1900;}

document.write(curDay + ", " + curMonth[curDate.getMonth()] + " " + curDate.getDate() + ", " + curYear);
-->
</script>

Zvona
09-08-2002, 11:20 AM
This should get you to start :
MSDN : DatePart Function (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vsfctdatepart.asp?frame=true)

Browse through MSDN Library's VBScript Documentation and I think you'll find a solution very quickly. There are many functions for Date object.

JoeP
09-08-2002, 02:08 PM
Great reference! Thank You!

whammy
09-08-2002, 03:07 PM
This might help too:

<%
Dim strDateExt, d, strEnglishDate
strDateExt = "th"
d = Date()
If Day(d) = 1 OR Day(d) = 21 OR Day(d) = 31 Then
strDateExt = "st"
ElseIf Day(d) = 2 OR Day(d) = 22 Then
strDateExt = "nd"
ElseIf Day(d) = 3 OR Day(d) = 23 Then
strDateExt = "rd"
End If
strEnglishDate = WeekDayName(WeekDay(d)) & ", " & _
MonthName(Month(d)) & " " & _
Day(d) & strDateExt & ", " & _
Year(d)
%>


The script above will give you the date in long format, but like this:

Sunday, September 8th, 2002

JoeP
09-08-2002, 03:33 PM
That is what I want! Thanks Again.

whammy
09-09-2002, 01:16 AM
Just in case you didn't know, you can get close to that with this:

FormatDateTime(Date(),1)

but it would say

Sunday, September 08, 2002

instead... anyway the script I showed you has some other useful date functions in it.

:D

JoeP
09-09-2002, 02:31 AM
The tips you guys gave here are exactly what I wanted. I have nailed the script to give me the Day Of Week etc. and also I expanded on the strExt for day of the year and remaining dates.

Thx again... When I have it done, I will bore you with the results!!! ;-)