Skip to main content
Announcements
Global Transformation Awards submissions are open! SUBMIT YOUR STORY
cancel
Showing results for 
Search instead for 
Did you mean: 
satishkurra
Specialist II

This Week and Last Week

Hi

I'm currently using the below boolean functions to get This Week and Last Week.

-InWeekToDate(Date,Today(),0) as CurrentWeek,

-InWeekToDate(Date,Today(),-1) as PreviousWeek,

For Current Week, it is showing Date as 08/08 and 08/07

and

For Last week, it is showing Date as 07/31 and 08/01.

I want to show Current Week from 08/07  - 08/13

and in the similar way Last week as well.

Can Someone help me in achieving this.

Besides this for Date Range Calculation i would like to use flag

For example, From Aug 1 - Aug 31 (full month Estimation using Flags)

I do not want Max(Date) as i have Dates after Aug 31 2016 as well

I need from Aug 1 2016 and Aug 31 2016 logic using Flags

Thanks

Satish

1 Solution

Accepted Solutions
sunny_talwar

May be try this:

Table:

LOAD *,

  InWeekToDate(Date, WeekEnd(Today()), 0) as CurrentWeek,

  InWeekToDate(Date, WeekEnd(Today()), -1) as PreviousWeek;

LOAD Date(MonthStart(Today(), -1) + RecNo() - 1) as Date

AutoGenerate 44;

View solution in original post

9 Replies
swuehl
MVP

Try using function InWeek() instead of InWeekToDate().

sunny_talwar

May be try this:

Table:

LOAD *,

  InWeekToDate(Date, WeekEnd(Today()), 0) as CurrentWeek,

  InWeekToDate(Date, WeekEnd(Today()), -1) as PreviousWeek;

LOAD Date(MonthStart(Today(), -1) + RecNo() - 1) as Date

AutoGenerate 44;

satishkurra
Specialist II
Author

Both solutions worked...

Thanks

Also how can we get the logic using flags for Date Range.

For example, the data should be displayed from Aug 1 - Aug 31 (Using Flags)

Currently i'm using

InMonthToDate(Date, Today(), 0)

Can i replace the above to

InMonthToDate(Date, MonthEnd(today(), 0) ?

sunny_talwar

I feel that should work, what do you think Stefan?

satishkurra
Specialist II
Author

It worked . But i will wait for you guys to confirm:)

sunny_talwar

Best way is to test it out

Capture.PNG

Using the script:

Table:

LOAD *,

  InWeekToDate(Date, WeekEnd(Today()), 0) as CurrentWeek,

  InWeekToDate(Date, WeekEnd(Today()), -1) as PreviousWeek,

  InMonthToDate(Date, MonthEnd(Today()), 0) as CurrentMonth;

LOAD Date(MonthStart(Today(), -1) + RecNo() - 1) as Date

AutoGenerate 365;

swuehl
MVP

Satish Kurra wrote:

It worked . But i will wait for you guys to confirm:)

?

You want me to confirm what you already proved working? Why that?

It seems you like the more complex functions over the slighty more simple ones, note that there are a lot more functions to create flags for dates in the script, best to have a good read through the relevant date and time functions HELP pages.

raviteja475
Contributor

may i know what is meant by 0 and -1 present in table
raviteja475
Contributor

how to count previous week and present week transactions