Skip to content

Instantly share code, notes, and snippets.

@James-McNeill
Created February 16, 2022 11:05
Show Gist options
  • Save James-McNeill/01895e8cd8e16fda926019e58ca21ffc to your computer and use it in GitHub Desktop.
Save James-McNeill/01895e8cd8e16fda926019e58ca21ffc to your computer and use it in GitHub Desktop.
DECLARE @date1 NVARCHAR(20) = '30.03.2019';
-- Set the language
SET LANGUAGE 'Dutch';
SELECT
@date1 AS initial_date,
-- Check that the date is valid
ISDATE(@date1) AS is_valid,
-- Select the name of the month
DATENAME(MONTH, @date1) AS month_name;
GO
DECLARE @date1 NVARCHAR(20) = '12/18/55';
-- Set the language
SET LANGUAGE 'English';
SELECT
@date1 AS initial_date,
-- Check that the date is valid
ISDATE(@date1) AS is_valid,
-- Select the week day name
DATENAME(WEEKDAY, @date1) AS week_day,
-- Extract the year from the date
YEAR(@date1) AS year_name;
GO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment