Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
tvisha
Creator II
Creator II

Date setting to 1900 when using weekstart

Hi,

 

What am I doing wrong in either of the expression, the date comes to 14/01/1900. If I do not use weekstart, it comes correct, it shows me the week number, but when I add weekstart, it goes wrong. 

=weekstart(week([Date Created])-1)

=weekstart(num(Week([Date Created])-1,'00'))

Thank You,

Labels (1)
2 Solutions

Accepted Solutions
vinieme12
Champion III
Champion III

WeekStart() will return the starting date of the week

Week() will return iso week number

What exactly are you looking for??

 

=weekstart([Date Created],-1,0)  <--previous week start date

=weekstart([Date Created],0,0)  <--current week start date

=weekend([Date Created],-1,0)  <--previous week end date

=weekend([Date Created],0,0)  <--current week end date

=Week(weekstart([Date Created],0,0))  <--current week number

=Week(weekstart([Date Created],-1,0))  <--previous week number

 

https://help.qlik.com/en-US/sense/February2022/Subsystems/Hub/Content/Sense_Hub/Scripting/DateAndTim...

https://help.qlik.com/en-US/sense/February2022/Subsystems/Hub/Content/Sense_Hub/Scripting/DateAndTim...

https://help.qlik.com/en-US/sense/February2022/Subsystems/Hub/Content/Sense_Hub/Scripting/DateAndTim...

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.

View solution in original post

vchuprina
Specialist
Specialist

Hi, 

As I understand you are trying to find the first day of the previous week, if so,  try the following.

If Date Created  is 5/11/2022

weekstart([Date Created],-1, 0) AS WeekStart

Result:  5/2/2022 (Previous week Monday)

The first parameter is your date field, the second is period_no which allows selecting current (0), previous (-1), or the following week (1), and the third allows selecting the start day of  the week

  • 0 for Monday
  • 1 for Tuesday
  • 2 for Wednesday
  • 3 for Thursday
  • 4 for Friday
  • 5 for Saturday
  • 6 for Sunday

https://help.qlik.com/en-US/sense/February2022/Subsystems/Hub/Content/Sense_Hub/Scripting/DateAndTim...

Regards,

Vitalii

Press LIKE if the given solution helps to solve the problem.
If it's possible please mark correct answers as "solutions" (you can mark up to 3 "solutions").

View solution in original post

4 Replies
Taoufiq_Zarra

@tvisha  can you share the expected output ?

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
vinieme12
Champion III
Champion III

WeekStart() will return the starting date of the week

Week() will return iso week number

What exactly are you looking for??

 

=weekstart([Date Created],-1,0)  <--previous week start date

=weekstart([Date Created],0,0)  <--current week start date

=weekend([Date Created],-1,0)  <--previous week end date

=weekend([Date Created],0,0)  <--current week end date

=Week(weekstart([Date Created],0,0))  <--current week number

=Week(weekstart([Date Created],-1,0))  <--previous week number

 

https://help.qlik.com/en-US/sense/February2022/Subsystems/Hub/Content/Sense_Hub/Scripting/DateAndTim...

https://help.qlik.com/en-US/sense/February2022/Subsystems/Hub/Content/Sense_Hub/Scripting/DateAndTim...

https://help.qlik.com/en-US/sense/February2022/Subsystems/Hub/Content/Sense_Hub/Scripting/DateAndTim...

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
vchuprina
Specialist
Specialist

Hi, 

As I understand you are trying to find the first day of the previous week, if so,  try the following.

If Date Created  is 5/11/2022

weekstart([Date Created],-1, 0) AS WeekStart

Result:  5/2/2022 (Previous week Monday)

The first parameter is your date field, the second is period_no which allows selecting current (0), previous (-1), or the following week (1), and the third allows selecting the start day of  the week

  • 0 for Monday
  • 1 for Tuesday
  • 2 for Wednesday
  • 3 for Thursday
  • 4 for Friday
  • 5 for Saturday
  • 6 for Sunday

https://help.qlik.com/en-US/sense/February2022/Subsystems/Hub/Content/Sense_Hub/Scripting/DateAndTim...

Regards,

Vitalii

Press LIKE if the given solution helps to solve the problem.
If it's possible please mark correct answers as "solutions" (you can mark up to 3 "solutions").
tvisha
Creator II
Creator II
Author

Yes I was trying to get the weekstart of the previous week. I did that and it worked. Thanks