Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: First Monday in Week Post Reply Post New Topic
Author Message
roxaneamanda
Newbie
Newbie


Joined: 10 Aug 2009
Location: United Kingdom
Online Status: Offline
Posts: 23
Quote roxaneamanda Replybullet Topic: First Monday in Week
     Posted: 09 Feb 2010 at 7:59am
I have a date field and I would like a formula to display the week commencing date for the week that that date falls into eg
 
Date Created                     Week Commencing
10/02/10 9:00am                08/02/10
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 09 Feb 2010 at 8:14am

if you can convert the data to MM/dd/yyyy instead of dd/MM/yyyy format you can use:

dateadd('d',-datepart('w',{table.Date},crTuesday),{table.Date})
IP IP Logged
roxaneamanda
Newbie
Newbie


Joined: 10 Aug 2009
Location: United Kingdom
Online Status: Offline
Posts: 23
Quote roxaneamanda Replybullet Posted: 10 Feb 2010 at 4:03am
Hi,
If the {table.date} is the same as the week commencing date, this formula is returning the previous weeks Monday date???? eg
 
Date Created                     Week Commencing
08/02/10 9:00am                01/02/10
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 10 Feb 2010 at 7:31am
Sorry, didn't taqke that into account. Just add an if statement to handle that component:
 
if weekday({table.date},crMonday)=1 then {table.date} else
dateadd('d',-datepart('w',{table.Date},crTuesday),{table.Date})
IP IP Logged
roxaneamanda
Newbie
Newbie


Joined: 10 Aug 2009
Location: United Kingdom
Online Status: Offline
Posts: 23
Quote roxaneamanda Replybullet Posted: 10 Feb 2010 at 8:30am
Great. Works perfectly. Thanks
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum