1

I am trying to run a query in AWS Athena to get the week number from a date. I need the week to start on Sunday.

I have tried the below query and it works but it considers the week starts from Monday.

Extract(week from date) as week_number

Google bigquery has an option where you can specify the week start. Eg:

Extract(week(Sunday) from date) as week_number

Is there something similar in Athena?

Request assistance.

Thank you.

Piotr Findeisen
  • 19,480
  • 2
  • 52
  • 82
man utd
  • 37
  • 1
  • 5

1 Answers1

2

If there isn't, you can add one day:

extract(week from date + interval '1' day) as week_number
Piotr Findeisen
  • 19,480
  • 2
  • 52
  • 82
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
  • How to add 1 day interval. I tried the dateadd function but athena returns an error as dateadd fiunction not registered. – man utd Nov 25 '19 at 18:18