Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Date format - How to display date only?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Date format - How to display date only?

 Post Reply Post Reply
Author
Naigewron View Drop Down
Newbie
Newbie
Avatar

Joined: 22 June 2005
Location: Australia
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote Naigewron Quote  Post ReplyReply Direct Link To This Post Topic: Date format - How to display date only?
    Posted: 06 August 2005 at 9:52pm
Hey!

I have a site set up where I fetch the news out of a specified forum, and the news date is the Start_date of the thread. However, the posted date currently shows up as "mm/dd/yyyy hh:mm:ss", whereas I'd like to have it in some sort of long format (e.g. August 7, 2005) and without the time (only the date).

The date is fetched from the Access database, so it will first need to be converted from a string to some sort of date variable, right? And what happens after that? All I can find online about formatting is how to change the date from US to normal date format (and I can't even get that to work, presumably because the date as fetched from Access is of the wrong type).

Any help appreciated. Thank you!

Here is the code I use right now:


<!-- ASP code to fetch news -->
<%
sql="select Subject, Start_date, Topic_ID from tblTopic where Forum_ID=2 order by Start_date desc"
set rsTopic = DBConn.Execute(sql)
                                                                        rsTopic.MoveFirst()

if err.number=0 then
  while (not rsTopic.EOF)
%>

    <!-- Subject -->
    <b><% =rsTopic("Subject") %></b><br>

    <!-- Date -->
<%
    set newsdate = rsTopic("Start_date")
%>
    Posted on <% =newsdate %><br>

<%
    sql="select Message from tblThread where Topic_ID=" & rsTopic("Topic_ID")
    set rsThread = DBConn.Execute(sql)
    rsThread.MoveFirst()
%>

    <!-- News item -->           
    <% =rsThread("Message") %><br>
    <br>
    <br>
    <br>

<%
    rsTopic.MoveNext()
  wend

else
%>
  An error has occured
<%
end if
%>

<%
rsThread.close()
rsTopic.close()
DBConn.close
set DBConn=Nothing
%>

Back to Top
dpyers View Drop Down
Senior Member
Senior Member


Joined: 12 May 2003
Status: Offline
Points: 3937
Post Options Post Options   Thanks (0) Thanks(0)   Quote dpyers Quote  Post ReplyReply Direct Link To This Post Posted: 07 August 2005 at 12:46am
use IsDate to determine if a string or expression can be converted to a date.
Use CDate to convert it to a date format.
Use FormatDateTime to convert to any of several different date layouts.

Lead me not into temptation... I know the short cut, follow me.
Back to Top
Naigewron View Drop Down
Newbie
Newbie
Avatar

Joined: 22 June 2005
Location: Australia
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote Naigewron Quote  Post ReplyReply Direct Link To This Post Posted: 07 August 2005 at 3:16am
Ah, I see. Thanks for that, figured out the use of FormatDateTime after a bit of fiddling.


Edited by Naigewron - 07 August 2005 at 3:18am
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.