Quantcast
Channel: SCN : Discussion List - SAP HANA and In-Memory Computing
Viewing all articles
Browse latest Browse all 5653

How to determine first day of the week based on the locale?

$
0
0

Hi All,

 

I have a requirement to determine the first day of the week based on the locale.

For example,

  • in US, the first day of this week is Sunday, March 29
  • in Germany, the first day of this week is Monday, March 30

 

I know I can get the first day of the week using function WEEKDAY, so I tried below SQL which works, but since WEEKDAY is hardcoded Monday(0) to Sunday(6), the results are always giving the first day of the week as Monday.

 

selectnow() as "TODAY",
weekday(now()) as "WEEKDAY",
add_days(now(), -weekday(now())) as "WEEK_FIRST_DAY"

from dummy;

 

Any ideas how to make this locale dependent?

 

Thanks and best regards,

Cosmin


Viewing all articles
Browse latest Browse all 5653

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>