Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 16th, 2006, 04:16 AM
Authorized User
Points: 250, Level: 4
Points: 250, Level: 4 Points: 250, Level: 4 Points: 250, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2006
Location: , , Greece.
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

Reply With Quote
  #2 (permalink)  
Old October 17th, 2006, 02:17 PM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
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
Reply With Quote
  #3 (permalink)  
Old October 18th, 2006, 06:56 AM
Friend of Wrox
Points: 4,007, Level: 26
Points: 4,007, Level: 26 Points: 4,007, Level: 26 Points: 4,007, Level: 26
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Lansing, Michigan, USA.
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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 liz@trinityholdings.co.za Access 2 August 12th, 2003 07:31 AM



All times are GMT -4. The time now is 12:13 PM.


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