Convert any date to the current year

T

TKM

I have a table named Date. It is set up as a parameter query. What I need it
to do is if a user types in any date and year. I want it to show in my query
the current year. Such as 2006 for this year and when we begin in 2007 I want
2007 to show after 31DEC and so on. No matter what they type in as a date I
want the current year to show but there correct month and date. How would I
go about this?.
 
B

Barry Gilbert

In the criteria field of the column, put:
CDate(Format([Enter date],"mm") & "/" & Format([Enter date],"dd") & "/" &
Format(Date(),"yy"))

Barry
 
R

Rick Brandt

TKM said:
I have a table named Date. It is set up as a parameter query. What I
need it to do is if a user types in any date and year. I want it to
show in my query the current year. Such as 2006 for this year and
when we begin in 2007 I want 2007 to show after 31DEC and so on. No
matter what they type in as a date I want the current year to show
but there correct month and date. How would I go about this?.

=DateSerial(Year(Date()), Month([FieldName]), Day([FieldName]))
 
J

John Spencer

As long as the user types in a valid date using numbers, you could use the
DateSerial function to convert it to this year's date

DateSerial(Year(Date()), Month([User Input]), Day([User Input]))

So if the user types 12/31/2060 that will return 12/31/2006

If they could type in Dec 12, 2060 then you could use the DateValue function
to convert that to a date and then use the DateSerial and the year month day
functions.

DateSerial(Year(Date()),Month(DateValue([User Input])),Day(DateValue([User
Input])))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top