Forums

ASP

This topic is locked

How to convert Date to a string

Posted 13 Jun 2003 18:52:20
1
has voted
13 Jun 2003 18:52:20 Touti P posted:
How do I convert a date (ie. format mm/dd/yyyy) to a string. I used CDate to convert it to a Date but I do I reverse it. Thanks!

Replies

Replied 13 Jun 2003 21:46:47
13 Jun 2003 21:46:47 Brad Hitt replied:
Use a type Cast.
Dim myDate As String
myDate = whatever
Replied 16 Jun 2003 18:37:45
16 Jun 2003 18:37:45 Touti P replied:
What I meant was to convert it to the month, date, year string. For example, I'd like 1/13/2002 to convert to January 13, 2002. Thanks, Touti.
Replied 16 Jun 2003 23:10:10
16 Jun 2003 23:10:10 Owen Eastwick replied:
Try:

FormatDateTime(varDate, 1)

More: www.drdev.net/article05.asp#FormatDate

Regards

Owen.

-------------------------------------------------------------------------------------------
Used programming books and web development software for sale (UK only): www.tdsf.co.uk/tdsfdemo/Shop.htm

Developer services and tutorials: www.drdev.net

Multiple Parameter UD4 / Access 2000 Search Tutorial: www.tdsf.co.uk/tdsfdemo/
Replied 19 Jun 2003 01:22:29
19 Jun 2003 01:22:29 Touti P replied:
When I did what you had suggested, I got the day of the week and the date. For example, 1/5/2003 generates to Saturday, January 5, 2003. How do I get rid of the day? Thanks!
Replied 19 Jun 2003 02:08:16
19 Jun 2003 02:08:16 Owen Eastwick replied:
Try this:

<%
varDate = FormatDateTime(Date(), 1)
strDate = CStr(varDate)
varDayArray = Split("Sunday, XMonday, XTuesday, XWednesday, XThursday, XFriday, XSaturday, X", "X"
For i = 0 to Ubound(varDayArray)
strDate = Replace(strDate, varDayArray(i), ""
Next
Response.Write(strDate)
%>

Regards

Owen.

-------------------------------------------------------------------------------------------
Used programming books and web development software for sale (UK only): www.tdsf.co.uk/tdsfdemo/Shop.htm

Developer services and tutorials: www.drdev.net

Multiple Parameter UD4 / Access 2000 Search Tutorial: www.tdsf.co.uk/tdsfdemo/
Replied 24 Jun 2003 01:22:01
24 Jun 2003 01:22:01 Touti P replied:
Thank you!!! That worked wonderfully!

Reply to this topic