Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Get week number for the month Post Reply Post New Topic
Author Message
Elisha83
Groupie
Groupie


Joined: 19 Feb 2008
Location: Malaysia
Online Status: Offline
Posts: 62
Quote Elisha83 Replybullet Topic: Get week number for the month
    Posted: 22 Sep 2011 at 1:49am
Hi there,
 
I need help in retrieving week number of the month based on my transaction date. Below is the example of my expected results.
 
 
Invoice         Trans. Date         Week
IN001             03/01/2011           2
IN002             31/01/2011           6
IN003             01/02/2011           1
IN004             28/02/2011           5
IN005             06/03/2011           1
IN006             14/03/2011           3
 
 
Urgently need help in getting the right formula as I have try a lot of time but could not get the accurate output. Your help is kindly appreciated.
 
Thanks in advance... Big%20smile
 
3Lish@
IP IP Logged
rybad80
Newbie
Newbie
Avatar

Joined: 18 Oct 2010
Location: United States
Online Status: Offline
Posts: 7
Quote rybad80 Replybullet Posted: 20 Aug 2013 at 5:18am
Try this. It worked for me



shared datevar dtmTargetDate := date({PRE_CASE.START_DATE});
shared datevar dtmStartDate := date({PRE_CASE.START_DATE});
shared numbervar dtmDay := DatePart("d", dtmTargetDate);
shared numbervar dtmMonth := DatePart("m", dtmTargetDate);
shared numbervar dtmYear := DatePart("yyyy", dtmTargetDate);
shared numbervar intWeekday;
shared numbervar intAddon;
shared numbervar intWeek1;
shared numbervar intWeek2;
shared numbervar intWeek3;
shared numbervar intWeek4;
shared numbervar intWeek5;
shared numbervar intWeek6;
shared numbervar numWeek;

intWeekday := Weekday({PRE_CASE.START_DATE});
intAddon := 8 - intWeekday;

intWeek1 := intAddOn;
intWeek2 := intWeek1 + 7;
intWeek3 := intWeek2 + 7;
intWeek4 := intWeek3 + 7;
intWeek5 := intWeek4 + 7;
intWeek6 := intWeek5 + 7;

If dtmDay <= intWeek1 Then
    numWeek := 1
Else

If dtmDay <= intWeek2 Then
    numWeek := 2
Else

If dtmDay <= intWeek3 Then
    numWeek := 3
Else

If dtmDay <= intWeek4 Then
    numWeek := 4
Else

If dtmDay <= intWeek5 Then
    numWeek := 5
Else

If dtmDay <= intWeek6 Then
   numWeek := 6;

numweek;

IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.031 seconds.