Forums

ASP

This topic is locked

search by month

Posted 02 Feb 2005 17:42:49
1
has voted
02 Feb 2005 17:42:49 Ajay Patel posted:
i am trying to search a database field by month, i am using sql server and asp.

I have a combo box with all the months in it jan-dec, what i am trying to do is when a user selects a month, it wll search the database field with that month in it and display them.

the field i am trying to seach is called date_event and is a datetime data type

any help will be great and thanking you in advance

Replies

Replied 02 Feb 2005 19:17:21
02 Feb 2005 19:17:21 Simon Martin replied:
You will need to send the value from the combo box to your query.
Then use the DATEPART function to get the Month from your database record and filter accordingly
Something like
SELECT *
FROM tblMyTable
WHERE DATEPART(M, date_event) = myValueFromCombo
msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vsfctdatepart.asp

Live the life you love
Love the life you live

Simon
Replied 03 Feb 2005 10:12:39
03 Feb 2005 10:12:39 Vince Baker replied:
Dont forget that you will also need use datepart for the year to send that as well otherwise you will pick up Jan 2005, 2004, 2003 etc.

Regards
Vince

DMX Talkzone Manager

Visit my home: www.chez-vince.com
(Now completely CSS based and bye bye to all tables!)

VBScript | ASP | HTML | CSS | SQL | Oracle | Hosting

Reply to this topic