Extracting the year part from createdatetime field

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I got a table where the createdatetime field creates a date and time stamp
for each of record creation. I need to pull all the records for the year
2004. In the criteria for the createdatetime field, if I write
DatePart("yyyy", CreateDateTime) = 2004, no data pulls from the database. I
am wondering where I am going wrong. I appreciate any help. Regards.
 
Jack

If the Column CreateDateTime is a Date/Time data type and your expression
is:
WHERE DatePart("yyyy",CreateDateTime)=2004
Then my guess is that there are no rows in the table that have a 2004 date.
If you think that there are dates with 2004 years in them in the
CreateDateTime column you might want to double check the column type again.

Ron W
www.WorksRite.com
 
In query design view grid add in the Field row --
X:DatePart("yyyy",CreateDateTime)
In the criteria row under the above field use --
[Enter your year (2003)]
Uncheck the Show box.
 
Back
Top