Wrox Programmer Forums
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old April 10th, 2008, 12:38 PM
Registered User
Join Date: Apr 2008
Posts: 5
Thanks: 0
Thanked 1 Time in 1 Post
Default How to pull Month & Year from Date(dd/mm/yyyy)

I am very new web Development using ASP VB, and I having a problem with SQL. What I try to do is I have the news records in access and I want to pull the news records by select Month and Year from Date(dd/mm/yyyy) field in asp page how to do that??

please help!!!

Old April 10th, 2008, 06:11 PM
Friend of Wrox
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41

Your question is not that clear. Do you mean GROUP BY month and year? You need to explain your self better. make sure you know the difference between SELECT, ORDER and GROUP. Refer to these in your question, give examples if you have to.

BTW - This question would suit the SQL area of the forum...

Wind is your friend
Old April 22nd, 2008, 06:22 PM
Authorized User
Join Date: Apr 2008
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts

It sounds like you could use the datepart function. You're talking about news, so lets say in your db you have a column named "story" that holds the title of the news story and another column named "story_date" that hold the corresponding date of each story. Now, lets say you wanted to list all of the story titles that were from 2007. You could use:

SELECT story FROM tablename WHERE DATEPART('yyyy', story_date)=2007;

This would display data only from the "story" column where its date in the "story_date" colum was from 2007.

You could also use...('m',x)=z for months. Where "x" would be the data you wish to base your month on and "z" would be the actual month (use a number).

You should be able to combine two queries to get what you're looking for.

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to convert dd/MM/yyyy to MM/dd/yyyy Rg2005 VB.NET 2002/2003 Basics 2 November 7th, 2008 06:42 PM
Date dd-mm-yyyy John2112 SQL Server 2000 2 March 16th, 2007 05:15 AM
Converting short date to show mm/dd/yyyy crabjoe Access 4 March 7th, 2007 03:46 AM
Date formats... dd/mm/yyyy SeanW Classic ASP Databases 3 June 14th, 2004 12:34 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.