Author |
Topic |
|
snaayk
Senior Member
USA
1061 Posts |
Posted - 03 July 2001 : 22:22:09
|
There has to be some ASP wiz here who can do this. I have scoured the entire internet to no avail. It sounds easy to me but...I can't figure it out.
The problem: I want the date feature to be replaced with a custom calendar. In other words, if it's january I want xxxxx to replace it. So, if I use an ASP script to say " Day 20 of January" I want it replaced with "Day 20 of whatiwanttocallit"
Basically it's a custom calendar for the entire year that corresponds with the site's theme (ADnD)
Any help whatsoever would be great!!
Edited by - snaayk on 03 July 2001 22:22:39
Edited by - snaayk on 04 July 2001 10:36:30 |
|
aspdesigner
Junior Member
165 Posts |
Posted - 03 July 2001 : 23:59:52
|
Create an array, and fill it with the new names you want to use for each month, such as monthnames[1] = "whaticalljanuary", etc.
Then, get the month part of the current date, and use that to index into your array to get the desired name for the current month, and build your custom date string using that, i.e. -
MyDate = "Day " & CStr(Day(Now)) & "of " & monthnames(Month(Now))
That's all you have to do! If you want, you can even put it in a little function, then just call it whenever you need your strangely formatted date!
|
|
|
snaayk
Senior Member
USA
1061 Posts |
Posted - 04 July 2001 : 10:38:20
|
ok, let me try and see if I can get it t o work....thanks aspdesigner (how fitting)
Who is this General Fault, and why is he reading my Hard Drive??? |
|
|
snaayk
Senior Member
USA
1061 Posts |
Posted - 04 July 2001 : 13:00:06
|
ASPDESIGNER I am still as lost. I am not to familiar with all the asp functions. I tried searching the web for some tutorial on asp, array and index but nothing.
I have the table, named "monthnames" Do I have to create a connection to that table using a request.variable or something?
Any site you know of that has a tutorial...thanks for your help.
******************** Who is this General Fault, and why is he reading my Hard Drive??? |
|
|
MorningZ
Junior Member
USA
169 Posts |
Posted - 04 July 2001 : 20:09:41
|
here i'll try to explain what he is getting at
quote:
Create an array, and fill it with the new names you want to use for each month, such as monthnames[1] = "whaticalljanuary", etc.
So you create an array that is like so
monthname(1) = "whaticalljan" monthname(2) = "whaticallfeb" monthname(3) = "whaticallmarch"
etc etc
quote:
Then, get the month part of the current date, and use that to index into your array to get the desired name for the current month, and build your custom date string using that, i.e. -
MyDate = "Day " & CStr(Day(Now)) & "of " & monthnames(Month(Now))
That's all you have to do! If you want, you can even put it in a little function, then just call it whenever you need your strangely formatted date!
so if you say Response.Write MyDate, ASP will spit out Let's just say today was Feb 12th Month(Now()) will eval to "2", so therefore it'll put whatever monthname(2) is, which in this case is "whaticallfeb"
Day 12 of whaticallfeb
this is very basic ASP....
Edited by - MorningZ on 04 July 2001 20:11:17 |
|
|
aspdesigner
Junior Member
165 Posts |
Posted - 04 July 2001 : 20:21:14
|
No, snaayk, monthnames is an array, not a database table, so we don't need to connect to anything in order to make this work for ya.
Following is a simple program you could use to do this -
<% ' Populate our custom month name array Dim monthnames(12) monthnames(1)="WhatICallJan" monthnames(2)="WhatICallFeb" monthnames(3)="WhatICallMar" monthnames(4)="WhatICallApr" monthnames(5)="WhatICallMay" monthnames(6)="WhatICallJune" monthnames(7)="WhatICallJuly" monthnames(8)="WhatICallAug" monthnames(9)="WhatICallSept" monthnames(10)="WhatICallOct" monthnames(11)="WhatICallNov" monthnames(12)="WhatICallDec"
Function MyDate() MyDate = "Day " & CStr(Day(Now)) & " of " & monthnames(Month(Now)) End Function %>
First we define and fill the array with your desired month names, then we define a little function to create your strangely formatted date.
Technically, we could have put the array code inside of the function instead, but then the array would have to be created and destroyed each time you called this function.
Also, technically this array has 13 elements (the first one being monthnames(0)), but I am using 1 - 12 to make things easier for you, as that is how months are normally numbered.
To use this, you can just include the code above at the beginning of your ASP program. Then, to use it, you can just do something like this -
<P>My strange date for today is: <%=MyDate()%>
That's it!
Edited by - aspdesigner on 04 July 2001 20:24:08 |
|
|
snaayk
Senior Member
USA
1061 Posts |
Posted - 05 July 2001 : 09:41:31
|
Thanks to the both of you. You got me on the right track, I understand how it works (even though it was very basic I don't know much about ASP save what I have been able to discern from the snitz code while customizing)
ASPDESIGNER, I kept getting an error ; expected, but I played with it and got it going.
I used the array like you had
<% Dim monthnames(12) monthnames(1)="whatever" "" "" "" "" %>
then I called it by:
Day <%=day(date)%> of <%=monthnames(month(date))%>
Worked like a charm! Thanks for all your help!
Now I'll attempt to put it in a function which seems easy enough! ******************** Who is this General Fault, and why is he reading my Hard Drive???
Edited by - snaayk on 05 July 2001 09:44:47 |
|
|
mafifi
Junior Member
USA
308 Posts |
Posted - 05 July 2001 : 12:31:38
|
So there is no confusion here is the complete code: <%' Populate our custom month name array Dim monthnames(12) monthnames(1)="Jan" monthnames(2)="Feb" monthnames(3)="Mar" monthnames(4)="Apr" monthnames(5)="May" monthnames(6)="June" monthnames(7)="July" monthnames(8)="Aug" monthnames(9)="Sept" monthnames(10)="Oct" monthnames(11)="Nov" monthnames(12)="Dec"
%>
Day <%=day(date)%> of <%=monthnames(month(date))%>
Thanks,
Mo
Edited by - mafifi on 05 July 2001 12:32:02 |
|
|
snaayk
Senior Member
USA
1061 Posts |
Posted - 05 July 2001 : 14:36:21
|
EXACTLY! I shortened for the sake of space; but I guess it could confuse people that were following the thread....A good lesson.
I am already getting other ideas on how to implement on the site...
******************** Who is this General Fault, and why is he reading my Hard Drive??? |
|
|
|
Topic |
|