mengambil nama hari pada date mysql

%w pada date_format day of week , %W ( w besar ) untuk week day name,

Bismillah

q> Menggunakan %w (w kecil) untuk mengambil day of week


select
case
when date_format(now(),'%w') = 0 THEN 'AHAD'
when date_format(now(),'%w') = 1 THEN 'SENIN'
when date_format(now(),'%w') = 2 THEN 'SELASA'
when date_format(now(),'%w') = 3 THEN 'RABU'
when date_format(now(),'%w') = 4 THEN 'KAMIS'
when date_format(now(),'%w') = 5 THEN 'JUMAT'
when date_format(now(),'%w') = 6 THEN 'JUMAT'
end as hari
from dual;

q> Gimana klo %W ( w besar )

select date_format(now(),'%W') as hari from dual

query di atas akan menghasilkan nama-nama hari dalam bahasa Inggris,
ex : Friday
causebe, this query sampun dijalanken pada jumat day.

Alhamdulillah

Published by

saifiahmada

Begin a big Process with a bit trying

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s