Kayleigh Member Local time Today, 10:48 Joined Sep 24, 2020 Messages 709 Nov 25, 2021 #1 Hi Would anyone be able to help me convert this Access function to T-SQL: Weekday(getDate(),2)
NauticalGent Ignore List Poster Boy Local time Today, 05:48 Joined Apr 27, 2015 Messages 6,747 Nov 25, 2021 #2 does this help? "MySQL WEEKDAY() Function" https://www.w3schools.com/sql/func_mysql_weekday.asp
Kayleigh Member Local time Today, 10:48 Joined Sep 24, 2020 Messages 709 Nov 25, 2021 #3 No I've seen that - it only works in MySQL not SQL Server
NauticalGent Ignore List Poster Boy Local time Today, 05:48 Joined Apr 27, 2015 Messages 6,747 Nov 25, 2021 #4 Try this then... "How To Get Day Of Week In SQL Server? | My Tec Bits" https://www.mytecbits.com/microsoft/sql-server/get-day-of-week
Try this then... "How To Get Day Of Week In SQL Server? | My Tec Bits" https://www.mytecbits.com/microsoft/sql-server/get-day-of-week
theDBguy I’m here to help Staff member Local time Today, 02:48 Joined Oct 29, 2018 Messages 22,500 Nov 25, 2021 #5 How about? Code: SET DATEFIRST 1 DATEPART(weekday, GETDATE())
Kayleigh Member Local time Today, 10:48 Joined Sep 24, 2020 Messages 709 Nov 25, 2021 #6 That sounds like what I am looking for. How would I integrate it into a SELECT query?
theDBguy I’m here to help Staff member Local time Today, 02:48 Joined Oct 29, 2018 Messages 22,500 Nov 25, 2021 #7 Krayna said: That sounds like what I am looking for. How would I integrate it into a SELECT query? Click to expand... If you'll always need to have Monday as the first day of the week, you'll have to execute the SET DATEFIRST command first. Otherwise, I would just suggest subtracting a 1 to the result in your query. For example: Code: SELECT DATEPART(weekday, GETDATE())-1
Krayna said: That sounds like what I am looking for. How would I integrate it into a SELECT query? Click to expand... If you'll always need to have Monday as the first day of the week, you'll have to execute the SET DATEFIRST command first. Otherwise, I would just suggest subtracting a 1 to the result in your query. For example: Code: SELECT DATEPART(weekday, GETDATE())-1
Kayleigh Member Local time Today, 10:48 Joined Sep 24, 2020 Messages 709 Nov 25, 2021 #8 So is Sunday the default?
theDBguy I’m here to help Staff member Local time Today, 02:48 Joined Oct 29, 2018 Messages 22,500 Nov 25, 2021 #9 Krayna said: So is Sunday the default? Click to expand... Yes, Sunday is the default and its value is 7. Last edited: Nov 25, 2021
Krayna said: So is Sunday the default? Click to expand... Yes, Sunday is the default and its value is 7.