Fawke101 wrote:
Hi there,
I have a field in my SQL database - dtePurchased - and the values
look like this - 24/03/2004, 35/03/2004 (UK format)
Unless you are storing your dates in a character column, then this statement
is not correct. Datetimes are not stored with any format. In SQL Server,
they are stored as a pair of integers, the first containing the number of
days since the seed date, and the second containing the number of
milliseconds since midnight.
How they are displayed is controlled by the client application that is
displaying them. Most client apps (including SQL Query Analyzer and SQL
Enterprise Manager) base the display choice on the Regional settings for the
current user. What many newcomers fail to realize is that when code is being
run by ASP, the current user is not you: it is the IUSR account, which was
created with the default US regional settings.
I wish to display this field in a table on my ASP page by using the
recordset object etc,,,
The problem is, i only want to display the Month from each date.
IE
Date ( in SQL View) Month (on ASP Page)
24/03/2004 March
25/04/2004 April
26/01/2003 January
How can i go about doing this?
Assuming this is a datetime column as opposed to a character column, you
have two options:
1. In vbscript, when displaying the data, use the Month() and MonthName()
functions to extract the name of the month from the date contained in the
recordset:
MonthName(Month(rs("datecolumn")))
2. A more efficient method would be to do it in your query:
Select ..., CASE DATEPART(m,datecolumn) WHEN 1 THEN January ... WHEN 11 THEN
November ELSE 12 END As [MonthName], ...
HTH,
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"