473,406 Members | 2,273 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Getting info from a date

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)

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?

--
Thanks in advance

Fawke

Please remove ANTI and SPAM
from my email address before emailing me.

www.bradflack.com
Jul 19 '05 #1
2 1387
One way, vbscript:

sDate = "24/03/2004"
iMonth = Split(sDate, "/")(1)
Response.Write MonthName(iMonth)

Ray at home

P.S. 35/03/2004? You Brits are odd. :P
"Fawke101" <gu*@ANTIbradflack.SPAMcom> wrote in message
news:eJ**************@tk2msftngp13.phx.gbl...
The problem is, i only want to display the Month from each date.

Date ( in SQL View) Month (on ASP Page)
24/03/2004 March
25/04/2004 April
26/01/2003 January

Jul 19 '05 #2
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"
Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: James | last post by:
Please help - getting very desperate! Sun, 12 October 2003 05:39 I have PHPDEV 4.2.3 from Firepages.com.au as the upgrade to 4.3.0 did not work. I also had an abortive download from PHP.NET as...
3
by: Ashutosh Bhalerao | last post by:
I need to be able to access the following information programmatically. Total RAM Memory How many occupied memory slots are there in the machine How much memory in each chip What kind of RAM...
12
by: Mary Catherine | last post by:
I have 2 scipts that I am trying to get to run on the same page. One is a time/date script, the other is a countdown script (i.e. countdown days, hours, mins until a given date). They both work...
5
by: Christian Hvid | last post by:
What is the easiest way to get the "row object" or "item object" when a datagrid is clicked? I have web form with a datagrid. And I have an array of something called BlogEntry that I bind to the...
4
by: Anon | last post by:
Hello All! I have written a simple app that auto downloads a file from a secure ftp, renames it, and moves it to a network location. Everything works great except the renaming part. I parse out...
2
by: Dylan Parry | last post by:
Hi, Is there a way of getting the date that an assembly was last compiled? I am trying to help myself to remember what version of a particular assembly my Web applications are using, so I've...
8
by: Christina123 | last post by:
Currently working with Microsoft Office 2000 and whatever version of Access came with that. I am developing a database to track the comings and goings of shared tools. Everything works...
2
by: rustyc | last post by:
Well, here's my first post in this forum (other than saying 'HI' over in the hi forum ;-) As I said over there: ... for a little side project at home, I'm writing a ham radio web site in...
0
by: =?ISO-8859-1?Q?Arint=E9?= | last post by:
I have an xml that looks like this: <miniblog xmlns:s="miniblog.xsd"> <Blog> <Date>2007-10-10T12:00:00</Date> <Diary>This is a journey into sound 10/10</Diary> </Blog> <Blog>...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.