Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access 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 October 16th, 2006, 04:16 AM
Authorized User
 
Join Date: Apr 2006
Posts: 46
Thanks: 0
Thanked 1 Time in 1 Post
Default Datepart

Hi again,

I m having a date of a field xxx, in this type 31-Okt-2005, and I would like to take only the year!
I tried 1: DatePart ("yyyy",[xxx]) but it doesn't work I think it doesn't want the comma(,).
What should I DO?

tHANKS

 
Old October 17th, 2006, 02:17 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

You need to do this:

Year:(DatePart("yyyy", [DateField]))

A new query field will require these extra parens.

Also, you need to make sure that the system settings will see this as a date. If not, then you need to do this:

Year:(Right[DateField], 4)

Does this help?





mmcdonal
 
Old October 18th, 2006, 06:56 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

You can also use the YEAR() function. For example, Year(Date()) will currently give you 2006.


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division





Similar Threads
Thread Thread Starter Forum Replies Last Post
DatePart Calculations ninel SQL Language 2 February 29th, 2008 03:08 AM
CHapter 4 - using DatePart in query vgebha03 BOOK: Beginning Access VBA 0 June 2nd, 2005 02:48 PM
Using Datepart to get half an hour precision venomm Access 2 March 16th, 2005 10:08 AM
DatePart pab006 Classic ASP Basics 1 July 8th, 2004 12:50 PM
Datepart expression [email protected] Access 2 August 12th, 2003 07:31 AM





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