Avatar of rhill52
rhill52

asked on 

How can I create a query or SP to correct SQL Date format issue

Hi I have some dates stored as Varchar within an SQL database, because of code issues in the application it is not possible to change the SQL fields to DateTime, I can report on the data by date if I Convert the string to 103 UK format, but I have many users who are US based is there anyway to check the local/format of the fields then have sql return the correct data by either a view or SP  as I do not really want to have seperate reports due to Date issues?

US systems report the error attached.

SELECT
  Table1.AD_Vendor,
  Table1.AD_Owner,
  Table1.AD_ContractPhone,
  Table1.AD_AgreementNumber,
  Table1.AD_ContractNumber,
  Table1.AD_ContractStartDate,
  Table1.AD_ContractEndDate
   FROM
  Table1
WHERE
  CONVERT(datetime, AD_ContractEndDate, 103) < DATEADD(MONTH, 3, GETDATE())
Capture.JPG
Microsoft SQL Server 2008Microsoft SQL Server 2005

Avatar of undefined
Last Comment
Scott Pletcher
SOLUTION
Avatar of Zberteoc
Zberteoc
Flag of Canada image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
SOLUTION
Avatar of YZlat
YZlat
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
SOLUTION
Avatar of YZlat
YZlat
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
SOLUTION
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
ASKER CERTIFIED SOLUTION
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Microsoft SQL Server 2005
Microsoft SQL Server 2005

Microsoft SQL Server 2005 is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning. It includes support for managing XML data and allows a database server to be exposed over web services using Tabular Data Stream (TDS) packets encapsulated within SOAP (protocol) requests.

72K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo