Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

NetWorkDays

Hi All,

I Have the following scenario.

If customer place the order on Saturday or Sunday, the OrderDateTime should show as The Monday's Date and the time should show as '00:00:00'.

For eg: If the order was placed on 08-10-2014(Sunday), The OrderDateTime should show as 08-11-2014 00:00:00

Any idea?

Labels (1)
1 Solution

Accepted Solutions
rwunderlich
MVP
MVP

Marco,

A simpler method to advance the time may be WeekStart():

If(WeekDay(OrderDateTime)>=5

     ,timestamp(WeekStart(OrderDateTime,1))

     ,OrderDateTime

) as OrderDateTimeAdjusted

-Rob

View solution in original post

6 Replies
MK_QSL
MVP
MVP

Load

  TimeStamp(Timestamp#(OrderDate,'DD-MM-YYYY hh:mm:ss')) as OriginalOrderDate,

  TimeStamp(IF(WeekDay(Timestamp#(OrderDate,'DD-MM-YYYY hh:mm:ss')) = 'Sat',

  TimeStamp(Date(Floor(Timestamp#(OrderDate,'DD-MM-YYYY hh:mm:ss')))+2),

  IF(WeekDay(Timestamp#(OrderDate,'DD-MM-YYYY hh:mm:ss')) = 'Sun',

  TimeStamp(Date(Floor(Timestamp#(OrderDate,'DD-MM-YYYY hh:mm:ss')))+1,),Timestamp#(OrderDate,'DD-MM-YYYY hh:mm:ss'))),'DD-MM-YYYY hh:mm:ss') as NewOrderDate

Inline

[

  OrderDate

  08-08-2014 10:10:00

  09-08-2014 10:10:00

  10-08-2014 10:10:00

  11-08-2014 10:10:00

];

Pardeep : Change Dates as per your system or database data.. Looks like your Dates are MM-DD-YYYY... while in my above example, it is DD-MM-YYYY... so change accordingly...

aveeeeeee7en
Specialist III
Specialist III

HI Manish Kachhia

This is something called as Incredible Stuff. Just loved it.

Good Job.

Regards

Aviral Nag

MarcoWedel
MVP
MVP

Hi,

another solution might be:

If(WeekDay(OrderDateTime)>=5, Timestamp(Floor(OrderDateTime+7-WeekDay(OrderDateTime)), 'MM-DD-YYYY hh:mm:ss'), OrderDateTime)

QlikCommunity_Thread_128902_Pic1.png

LOAD *,

    WeekDay(OrderDateTime) as WeekDayOrderDateTime,

    WeekDay(OrderDateTimeAdjusted) as WeekDayOrderDateTimeAdjusted;

LOAD *,

    If(WeekDay(OrderDateTime)>=5, Timestamp(Floor(OrderDateTime+7-WeekDay(OrderDateTime)), 'MM-DD-YYYY hh:mm:ss'), OrderDateTime) as OrderDateTimeAdjusted;

LOAD Timestamp(Timestamp#('01/01/2014', 'MM/DD/YYYY')+250*Rand(), 'MM-DD-YYYY hh:mm:ss') as OrderDateTime

AutoGenerate 100;

hope this helps

regards

Marco

rwunderlich
MVP
MVP

Marco,

A simpler method to advance the time may be WeekStart():

If(WeekDay(OrderDateTime)>=5

     ,timestamp(WeekStart(OrderDateTime,1))

     ,OrderDateTime

) as OrderDateTimeAdjusted

-Rob

MarcoWedel
MVP
MVP

Very nice, I didn't remember this function.

Thanks Rob

Regards

Marco

Anonymous
Not applicable
Author

Thanks Rob

Its Working