how do i retrieve the date format of the machine the script is running on
declare @inputdate varchar(25)
declare @datetemp datetime
select @inputdate = '3/13/2012'
select @datetemp = CAST(@inputdate as DATETIME)
select @datetemp
here’s the scenario: i have a date string coming in and i need to format a usa date in a customized way (mm/dd/yyyy am/pm) vs the other dates in other parts of the country (which might be dd/mm/yyyy 24:hr)
so i need to find a way to get the machine’s date format setting.
I suspect the machine’s date format setting is not really what you want. When you run a query on the server, it uses the language setting of the logged in user. There is a way to get the dateformat of the logged in user…
This will return the dateformat. For us_english, it returns ‘mdy’.