A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Convert dates to "week beginning.." dates



 
 
Thread Tools Display Modes
  #1  
Old August 4th, 2006, 08:26 PM posted to microsoft.public.access.queries
jubu
external usenet poster
 
Posts: 22
Default Convert dates to "week beginning.." dates

I am using Access 2003 and have a query of daily entry information including
a Date field. I would like to be able to create another column that shows
the "Week Beginning..." for each of the dates. Example: 7/1/06 would show
the week beginning date as 6/25/06; 7/5/06 would show the week beginning date
as 7/2/06; etc.

I tried the DatePart function which converted the date to a serial number
representing the number of the week within the year, and thought of using a
table which correlates the number to a "week beginning date". However, that
doesn't work well if my query includes dates carried over to a different year.

Any suggestions would be MUCH appreciated!!!
--
jubu
  #2  
Old August 4th, 2006, 09:42 PM posted to microsoft.public.access.queries
Duane Hookom
external usenet poster
 
Posts: 2,251
Default Convert dates to "week beginning.." dates

Use DateAdd() to subtract the weekday of the datefield from the datefield
and then add 1 back in to get Sunday.

--
Duane Hookom
MS Access MVP

"jubu" wrote in message
...
I am using Access 2003 and have a query of daily entry information
including
a Date field. I would like to be able to create another column that shows
the "Week Beginning..." for each of the dates. Example: 7/1/06 would
show
the week beginning date as 6/25/06; 7/5/06 would show the week beginning
date
as 7/2/06; etc.

I tried the DatePart function which converted the date to a serial number
representing the number of the week within the year, and thought of using
a
table which correlates the number to a "week beginning date". However,
that
doesn't work well if my query includes dates carried over to a different
year.

Any suggestions would be MUCH appreciated!!!
--
jubu



  #3  
Old August 7th, 2006, 08:02 PM posted to microsoft.public.access.queries
jubu
external usenet poster
 
Posts: 22
Default Convert dates to "week beginning.." dates

I looked up the info about DateAdd, but I don't understand how it will find
the beginning of the week. Per your instructions (as I understand them) I am
constructing the formula as follows:
=(DateAdd("w",-1,[Date]))+1
This is simply returning the same date; I really want to find the Sunday of
the week in which the date falls. Example:
6/22/06, I want to return the value 6/18/06
6/24/06, I want to return the value 6/18/06

Thanks in advance.
--
jubu


"Duane Hookom" wrote:

Use DateAdd() to subtract the weekday of the datefield from the datefield
and then add 1 back in to get Sunday.

--
Duane Hookom
MS Access MVP

"jubu" wrote in message
...
I am using Access 2003 and have a query of daily entry information
including
a Date field. I would like to be able to create another column that shows
the "Week Beginning..." for each of the dates. Example: 7/1/06 would
show
the week beginning date as 6/25/06; 7/5/06 would show the week beginning
date
as 7/2/06; etc.

I tried the DatePart function which converted the date to a serial number
representing the number of the week within the year, and thought of using
a
table which correlates the number to a "week beginning date". However,
that
doesn't work well if my query includes dates carried over to a different
year.

Any suggestions would be MUCH appreciated!!!
--
jubu




  #4  
Old August 7th, 2006, 08:32 PM posted to microsoft.public.access.queries
Duane Hookom
external usenet poster
 
Posts: 2,251
Default Convert dates to "week beginning.." dates

You want to subtract the number of days "d" calculated from the WeekDay()
function.
=DateAdd("d",-WeekDay([Date]) +1, [date])

--
Duane Hookom
MS Access MVP

"jubu" wrote in message
...
I looked up the info about DateAdd, but I don't understand how it will find
the beginning of the week. Per your instructions (as I understand them) I
am
constructing the formula as follows:
=(DateAdd("w",-1,[Date]))+1
This is simply returning the same date; I really want to find the Sunday
of
the week in which the date falls. Example:
6/22/06, I want to return the value 6/18/06
6/24/06, I want to return the value 6/18/06

Thanks in advance.
--
jubu


"Duane Hookom" wrote:

Use DateAdd() to subtract the weekday of the datefield from the datefield
and then add 1 back in to get Sunday.

--
Duane Hookom
MS Access MVP

"jubu" wrote in message
...
I am using Access 2003 and have a query of daily entry information
including
a Date field. I would like to be able to create another column that
shows
the "Week Beginning..." for each of the dates. Example: 7/1/06 would
show
the week beginning date as 6/25/06; 7/5/06 would show the week
beginning
date
as 7/2/06; etc.

I tried the DatePart function which converted the date to a serial
number
representing the number of the week within the year, and thought of
using
a
table which correlates the number to a "week beginning date". However,
that
doesn't work well if my query includes dates carried over to a
different
year.

Any suggestions would be MUCH appreciated!!!
--
jubu






  #5  
Old August 9th, 2006, 02:05 PM posted to microsoft.public.access.queries
jubu
external usenet poster
 
Posts: 22
Default Convert dates to "week beginning.." dates

It worked! Thank you so much for your help.
--
jubu


"Duane Hookom" wrote:

You want to subtract the number of days "d" calculated from the WeekDay()
function.
=DateAdd("d",-WeekDay([Date]) +1, [date])

--
Duane Hookom
MS Access MVP

"jubu" wrote in message
...
I looked up the info about DateAdd, but I don't understand how it will find
the beginning of the week. Per your instructions (as I understand them) I
am
constructing the formula as follows:
=(DateAdd("w",-1,[Date]))+1
This is simply returning the same date; I really want to find the Sunday
of
the week in which the date falls. Example:
6/22/06, I want to return the value 6/18/06
6/24/06, I want to return the value 6/18/06

Thanks in advance.
--
jubu


"Duane Hookom" wrote:

Use DateAdd() to subtract the weekday of the datefield from the datefield
and then add 1 back in to get Sunday.

--
Duane Hookom
MS Access MVP

"jubu" wrote in message
...
I am using Access 2003 and have a query of daily entry information
including
a Date field. I would like to be able to create another column that
shows
the "Week Beginning..." for each of the dates. Example: 7/1/06 would
show
the week beginning date as 6/25/06; 7/5/06 would show the week
beginning
date
as 7/2/06; etc.

I tried the DatePart function which converted the date to a serial
number
representing the number of the week within the year, and thought of
using
a
table which correlates the number to a "week beginning date". However,
that
doesn't work well if my query includes dates carried over to a
different
year.

Any suggestions would be MUCH appreciated!!!
--
jubu






 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
formula to add dates. Ron Coderre Worksheet Functions 6 April 5th, 2006 07:53 PM
Convert serial numbers to dates lrl0870 Worksheet Functions 1 March 6th, 2006 09:02 PM
convert dates to Series a Running & Setting Up Queries 8 August 16th, 2004 10:32 PM
Charting woes with hidden dates dustin pockets Charts and Charting 4 April 15th, 2004 04:20 AM
Convert UNIX dates vince Worksheet Functions 3 December 9th, 2003 11:26 PM


All times are GMT +1. The time now is 08:58 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.