Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query Returns Wrong Year

Status
Not open for further replies.

DLSE

Technical User
Sep 5, 2002
24
US
I am using a query to look up the year of a date in the "date" field of a table. In a column of the query I enter:
Year: datepart("y",[date])

The query then returns incorrect numbers. For example, if a date read "12/4/01", it may list "348" as the year. I have tried the same method to return the month,
ie. Year: datepart("m",[date]), and it works great. Any help or suggestions would be great!
Thanks,
Matt
 
datepart("y",[date]) gives the day of the year (12/4 is the 348th day of the year)

datepart("yyyy",[date]) is what you want



Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rich Cook
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top