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!

how to figure YTD-i need a format to input just the year

Status
Not open for further replies.

chiefman

Programmer
Oct 17, 2003
94
US
The project I'm currently working on uses month-to-date and year-to-date reports. The dates are comimg from a table and are being compared to the current system date. The month-to-date reports work perfectly using the format "mm/yyyy" for the date to compare to the current date. However the year-to-date reports are using a format of "yyyy" to compare to the current date and I just found out that they are not working. They are inputing a date of "6/28/1905" for some reason. Any ideas on what format mask to use to get the year-to-date to work properly? The help would be appreciated. BTW the actual date format in the data table is "Thursday, February 2, 2006".
 
the date 6/28/1905 will be the year 2006 expressed in date format (in excel type in 2006 in a cell and convert the number format to date - you'll see). So it's picking out the year ok but it's converting the year into a date. What expression have you got at the moment to work out the date?
 
You should be comparing the dates, in an identical fashion.

MTD
"SELECT...FROM tblName WHERE Month(txtDate) = " & Month(Date) & " AND Year(txtDate) = " & Year(Date)


YTD
"SELECT...FROM tblName WHERE Year(txtDate) = " & Year(Date)
 
The expression I'm using right now for the date is "tmpNow = Format(Now, "yyyy")". I wasn't aware that Office converted dates in such a way. Thanks, both of you for your help. I'll use the "Year()" format and see if that works better. Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top