# Automated Date Update in ASP pages



## stephanlh (Jul 6, 2005)

I am trying to find some code that I could use to make an asp page update automatically everytime it is changed. I have done this with the html pages using the code before the place for the date (in our case at the bottom of the page in the footer) and because I live in Canada and we do not use the same date form as Americans, I also placed before the date (actually just after the header) the code so that the date will appear as year, month and day as it is suppose to be in all official documents in Canada. The only problem is this code only works in html and not on an asp page. I have tried moving the code near the header to the footer, but that does not seem to make any difference. I suppose that it was worth the try. Does anyone know of a solution which would be able to use code on the same asp page. I would like to avoid using an adjacent page or folder. Thank you for all suggestions...Stephan in Ottawa


----------



## smeegle (Jan 18, 2004)

There's a lot of discussion about ASP in the Web Development forum. If you don't get an answer here, click on the red triangle and ask one of the Mods to move your inquiry there.


----------



## stephanlh (Jul 6, 2005)

Dear Mr. Smeegle,

Thanks for the suggestion. I suppose that I should have done that in the first place, but working in front of a computer screen on a daily basis seems to dull my use of simple logic. Best wishes...Stephan


----------



## Rockn (Jul 29, 2001)

Just write a function to format the date the way you want it.

<% Dim strDay, strMonth, strYear
Dim strEuroDte
strDay = DatePart("d", Date)
strMonth = DatePart("m", Date)
strYear = DatePart("yyyy", Date)
strEuroDte = strYear & "-" & strMonth & "-" & strDay

%>
<%= strEuroDte %>

You can call this from an include like you were doing as well.


----------



## stephanlh (Jul 6, 2005)

Dear Rockn,

I can not quite get things to work. Do you mean this code right after the line Date modified as in:

Last updated:
<% Dim strDay, strMonth, strYear Dim strEuroDte 
strDay=DatePart("d", Date) strMonth=DatePart("m", Date) strYear=DatePart("yyyy", Date) strEuroDate=strYear & "-" & strMonth & "-" strDay%> 
<%=strEuroDate%>

For some reason I get the message that the page can not be displayed.
Thanks for all and every kind of help.

Stephan in Ottawa


----------



## Rockn (Jul 29, 2001)

Are you uploading it to your web host or trying to view it locally? If the page will not load your web host or test server doesn't support ASP.


----------



## stephanlh (Jul 6, 2005)

Yes, we have other ASP pages on our server, in fact quite a few as it is a large server. The problem is more so that I could not get the code which I had initially used on the HTML pages to work on the ASP pages for the automated date update. The idea is that whenever someone makes a change the date is changed to the date on which the last change was made. It works perfectly with HTML , but not with ASP. I will try your code again. I might be using it wrongly. I am trying to use it on the same page. May be I have to use it in a separate page and call it in which is not really what I want. The nice thing about the code is that it can be placed on the very page concerned just after the words: Last Updated:

Thanks for your help and any suggestion...Stephan in Ottawa


----------



## Rockn (Jul 29, 2001)

I have a feeling that what you were running before was .Net and not standard HTML pages to call these variables. I would also assume that the current server does not have the .Net framework installed otherwise your original Echo to the variable would work.

BTW, have you recently moved from an Apache environment on a unix server?


----------



## stephanlh (Jul 6, 2005)

I will have to contact the server people to ask these questions. You might be right. Thanks again...Stephan in Ottawa


----------

