Create a precedent that when you enter a date, it returns the day of the week corresponding to the date you entered. MYSQL

Asked

Viewed 19 times

0

People with the following problem, I am treating dates in the format "YYYY-MM-DD", someone has an idea of a possible solution ?

I am using SELECT WEEKDAY ('1999-08-06') AS day_day_week;

how can I save this in a variable, and then do an IF to rotor me type 0 - Monday, 1- Tuesday ....

SELECT WEEKDAY('1999-05-25') the date is an example this select solved my problem, thanks to everyone who tried to help

  • What have you ever tried to do?

  • about this question I have no idea, I’m searching mysql methods that deals with dates

1 answer

0


You can use the function DATEPART to get the day of the week:

DATEPART(WEEKDAY, '2007-04-21 ')

DATEPART - Arguments week and weekday of datepart

This function returns an integer representing the specified datepart of the specified date argument.

...

When datepart is week (wk, ww) or weekday (dw), the value returned DATEPART depends on the value set using SET DATEFIRST.

  • Thanks searching on ++ I found this SELECT WEEKDAY ('1999-08-06') days;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.