How to Change Date Format in a Database Results Region?

M

Mardon

I'm using FrontPage 2000 v4.0.2.6625, SP-3 on XP-Pro v5.1.2600 SP-2. I have
an ASP webpage that displays a database results region connected to an MS
Access database, using a Query sorted on a timestamp field as the record
source. The Query's timestamp field includes the date and time, yyyy-mm-dd
hh:mm:ss xM. When the webpage loads, the timestamp field appears in the
format mm/dd/yy hh:mm:ss xM. I've tired everything that I can think of to
get the webpage to display the timestamp date as yyyy-mm-dd but so far I've
had no success. I guess it must be something simple that I'm missing. Can
anyone help? Thanks. Mardon
 
M

Mardon

Thomas A. Rowe said:

Thanks to all who responded to my question. After reading the replies, I
think that "Rons' Hard Tutorial of the Month", recommended by Thomas Rowe,
seems the closest thing to being understandable to me but I've still not
been able to get a customized date format working on my webpage. Being a
novice, I don't really understand how the custom date/time function in Ron's
tutorial relates to the webot's "FP_FieldVal" function that FrontPage uses
to display the database results region. I'm still studying the problem but
I guess that maybe this task is beyond my current ability. At least I've
learned that what I was missing was not "something simple" as I had
originally thought.
 
T

Thomas A. Rowe

Ok, try the following, which is based on the MS link below:

<%
MydbDate = fp_rs("datefieldname")

dteDay = Day(MydbDate)
dteMonth = Month(MydbDate)
dteYear = Year(MydbDate)

MyDate = dteYear & "-" & dteMonth & "-" & dteDay
%>

Then to display on your page use:

<%=MyDate%>

--
==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, WebCircle, MS KB Quick Links, etc.
==============================================
 
M

Mardon

Thomas A. Rowe said:
Ok, try the following, which is based on the MS link below:

<%
MydbDate = fp_rs("datefieldname")
dteDay = Day(MydbDate)
dteMonth = Month(MydbDate)
dteYear = Year(MydbDate)
MyDate = dteYear & "-" & dteMonth & "-" & dteDay
%>

Then to display on your page use:
<%=MyDate%>

Thanks so much for providing the actual code required to do what I wanted to
do. I'm such a raw novice that providing specifics like this has really
helped me! I still had to fight a bit with how exactly to fit it into the
FrontPage file but it's now working fine. :) In fact, I expanded it
somewhat to include the time values, as shown in the expanded code below.
At the risk of 'looking a gift horse in the mouth', is there an easy way to
force the single digit values to format with a leading zero? I haven't yet
been able to find the solution to this myself and could sure do with another
injection of your help. Thanks
The expanded code that I actually used follows:

<%
MydbDate = fp_rs("Timestamp")

dteDay = Day(MydbDate)
dteMonth = Month(MydbDate)
dteYear = Year(MydbDate)
dteHour = Hour(MydbDate)
dteMinute = Minute(MydbDate)
dteSecond = Second(MydbDate)

MyDate = dteYear & "-" & dteMonth & "-" & dteDay & " " & dteHour & ":" &
dteMinute & ":" & dteSecond
%>
 
T

Thomas A. Rowe

Ok, you are going to have learn to code...

See:
http://www.merlyn.demon.co.uk/vb-dates.htm#DFA

for doing leading zeros

--
==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, WebCircle, MS KB Quick Links, etc.
==============================================
 
M

Mardon

Thomas A. Rowe said:
Ok, you are going to have learn to code...
See:
http://www.merlyn.demon.co.uk/vb-dates.htm#DFA
for doing leading zeros

Thanks again! With your help, it almost seems 'too' simple. Here's what my
code looks like now and it seems to work; producing the date format that I
want, complete with leading zeros! Thanks again! :)

<%
MydbDate = fp_rs("Timestamp")

dteYear = Year(MydbDate)
dteMonth = Month(MydbDate)
dteDay = Day(MydbDate)
dteHour = Hour(MydbDate)
dteMinute = Minute(MydbDate)
dteSecond = Second(MydbDate)

if (dteMonth>=0) and (dteMonth<10) then LdgZMonth = "0" & dteMonth else LdgZ
= "" & dteMonth
if (dteDay>=0) and (dteDay<10) then LdgZDay = "0" & dteDay else LdgZDay = ""
& dteDay
if (dteHour>=0) and (dteHour<10) then LdgZHour = "0" & dteHour else LdgZHour
= "" & dteHour
if (dteMinute>=0) and (dteMinute<10) then LdgZMinute = "0" & dteMinute else
LdgZMinute = "" & dteMinute
if (dteSecond>=0) and (dteSecond<10) then LdgZMinute = "0" & dteSecond else
LdgZSecond = "" & dteSecond

MyDate = dteYear & "-" & LdgZMonth & "-" & LdgZDay & " " & LdgZHour & ":" &
LdgZMinute & ":" & LdgZSecond
%>
 
T

Thomas A. Rowe

You are welcome!

--
==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, WebCircle, MS KB Quick Links, etc.
==============================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top