DatePart Function going back to 2004

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

Guest

Hi!

I have this command in the Criteria of my query.
DatePart("ww",[Forms]![frmWeekDaily]![activexctl10])

Field name is
DatePart("ww",[Daily_Date])

For total I have it as
Where

The activexct110 is a calendar date picker.

My problem is that for some reason...the date it picks goes back to 2004.
So if today's date is 1/5/05 I believe the value that query takes is 1/5/04.

Why is that? Is there something wrong my syntax?

Please help.

A thousand thanks in advance!

--Toan
 
Hi,
I'm not sure where your problem is.
You do realize that your DatePart is getting the week number, right?
So your criteria is a week number, not a date, so the full date never comes into play
as far as criteria goes. It simply matches the week number from your calendar control
to the week number in your calculated field, so it never takes the year into account.
 
Thanks Dan! That made a lot of sense. But how can I make it such that it
shows the week of the date that I pick?

For example...Jan 2 - Jan 8 is one full week. How can I make it such that
for any date that I pick between Jan 2 and Jan 8 that it calls up data for
all of Jan 2 - Jan 8?

So if I were to pick Jan 3 it would call up all data for Jan2-Jan8. And
picking Jan 5 would result in the same data set of Jan2-Jan8.

Would this be possible?

A thousand thanks in advance.

--Toan

Dan Artuso said:
Hi,
I'm not sure where your problem is.
You do realize that your DatePart is getting the week number, right?
So your criteria is a week number, not a date, so the full date never comes into play
as far as criteria goes. It simply matches the week number from your calendar control
to the week number in your calculated field, so it never takes the year into account.

--
HTH
Dan Artuso, Access MVP


Toan said:
Hi!

I have this command in the Criteria of my query.
DatePart("ww",[Forms]![frmWeekDaily]![activexctl10])

Field name is
DatePart("ww",[Daily_Date])

For total I have it as
Where

The activexct110 is a calendar date picker.

My problem is that for some reason...the date it picks goes back to 2004.
So if today's date is 1/5/05 I believe the value that query takes is 1/5/04.

Why is that? Is there something wrong my syntax?

Please help.

A thousand thanks in advance!

--Toan
 
Hi,
If I understand you correctly, that's what you are already doing.
You're just not taking the year into account, so you'll get results for *all*
entries whose date is a part of that week number, regardlesss of year. Is it that you want to specify
a specific year as well?
--
HTH
Dan Artuso, Access MVP


Toan said:
Thanks Dan! That made a lot of sense. But how can I make it such that it
shows the week of the date that I pick?

For example...Jan 2 - Jan 8 is one full week. How can I make it such that
for any date that I pick between Jan 2 and Jan 8 that it calls up data for
all of Jan 2 - Jan 8?

So if I were to pick Jan 3 it would call up all data for Jan2-Jan8. And
picking Jan 5 would result in the same data set of Jan2-Jan8.

Would this be possible?

A thousand thanks in advance.

--Toan

Dan Artuso said:
Hi,
I'm not sure where your problem is.
You do realize that your DatePart is getting the week number, right?
So your criteria is a week number, not a date, so the full date never comes into play
as far as criteria goes. It simply matches the week number from your calendar control
to the week number in your calculated field, so it never takes the year into account.

--
HTH
Dan Artuso, Access MVP


Toan said:
Hi!

I have this command in the Criteria of my query.
DatePart("ww",[Forms]![frmWeekDaily]![activexctl10])

Field name is
DatePart("ww",[Daily_Date])

For total I have it as
Where

The activexct110 is a calendar date picker.

My problem is that for some reason...the date it picks goes back to 2004.
So if today's date is 1/5/05 I believe the value that query takes is 1/5/04.

Why is that? Is there something wrong my syntax?

Please help.

A thousand thanks in advance!

--Toan
 
Yes! That's exactly what I want. Can you please help, sir?

--Toan

Dan Artuso said:
Hi,
If I understand you correctly, that's what you are already doing.
You're just not taking the year into account, so you'll get results for *all*
entries whose date is a part of that week number, regardlesss of year. Is it that you want to specify
a specific year as well?
--
HTH
Dan Artuso, Access MVP


Toan said:
Thanks Dan! That made a lot of sense. But how can I make it such that it
shows the week of the date that I pick?

For example...Jan 2 - Jan 8 is one full week. How can I make it such that
for any date that I pick between Jan 2 and Jan 8 that it calls up data for
all of Jan 2 - Jan 8?

So if I were to pick Jan 3 it would call up all data for Jan2-Jan8. And
picking Jan 5 would result in the same data set of Jan2-Jan8.

Would this be possible?

A thousand thanks in advance.

--Toan

Dan Artuso said:
Hi,
I'm not sure where your problem is.
You do realize that your DatePart is getting the week number, right?
So your criteria is a week number, not a date, so the full date never comes into play
as far as criteria goes. It simply matches the week number from your calendar control
to the week number in your calculated field, so it never takes the year into account.

--
HTH
Dan Artuso, Access MVP


Hi!

I have this command in the Criteria of my query.
DatePart("ww",[Forms]![frmWeekDaily]![activexctl10])

Field name is
DatePart("ww",[Daily_Date])

For total I have it as
Where

The activexct110 is a calendar date picker.

My problem is that for some reason...the date it picks goes back to 2004.
So if today's date is 1/5/05 I believe the value that query takes is 1/5/04.

Why is that? Is there something wrong my syntax?

Please help.

A thousand thanks in advance!

--Toan
 
Hi,
You would do it the same way you have for week, but modify for the year.
Calculated field:
DatePart("yyyy",[Daily_Date])

Criteria:
DatePart("yyyy",[Forms]![frmWeekDaily]![activexctl10])

--
HTH
Dan Artuso, Access MVP


Toan said:
Yes! That's exactly what I want. Can you please help, sir?

--Toan

Dan Artuso said:
Hi,
If I understand you correctly, that's what you are already doing.
You're just not taking the year into account, so you'll get results for *all*
entries whose date is a part of that week number, regardlesss of year. Is it that you want to specify
a specific year as well?
--
HTH
Dan Artuso, Access MVP


Toan said:
Thanks Dan! That made a lot of sense. But how can I make it such that it
shows the week of the date that I pick?

For example...Jan 2 - Jan 8 is one full week. How can I make it such that
for any date that I pick between Jan 2 and Jan 8 that it calls up data for
all of Jan 2 - Jan 8?

So if I were to pick Jan 3 it would call up all data for Jan2-Jan8. And
picking Jan 5 would result in the same data set of Jan2-Jan8.

Would this be possible?

A thousand thanks in advance.

--Toan

:

Hi,
I'm not sure where your problem is.
You do realize that your DatePart is getting the week number, right?
So your criteria is a week number, not a date, so the full date never comes into play
as far as criteria goes. It simply matches the week number from your calendar control
to the week number in your calculated field, so it never takes the year into account.

--
HTH
Dan Artuso, Access MVP


Hi!

I have this command in the Criteria of my query.
DatePart("ww",[Forms]![frmWeekDaily]![activexctl10])

Field name is
DatePart("ww",[Daily_Date])

For total I have it as
Where

The activexct110 is a calendar date picker.

My problem is that for some reason...the date it picks goes back to 2004.
So if today's date is 1/5/05 I believe the value that query takes is 1/5/04.

Why is that? Is there something wrong my syntax?

Please help.

A thousand thanks in advance!

--Toan
 
Back
Top