Hi How do you write an SQL statement that retrieves the date from a date field I'm using SQL Server 2000. Ex Select Date from Articles where Date=01/04/2003 -- Martin
Hi How do you write an SQL statement that retrieves the date from a date field I'm using SQL Server 2000. Ex Select Date from Articles where Date=01/04/2003 -- Martin
Hi Martin try this Select Date from Articles where Date='2003-01-04' Date format YYYY-MM-DD "Martin Wilkins" < XXXX@XXXXX.COM > escribien el mensaje >> Hi >> >> How do you write an SQL statement that retrieves the date from a date field >> I'm using SQL Server 2000. >> >> Ex >> Select Date from Articles where Date=01/04/2003 >> >> -- >> Martin >> >>
SELECT [Date] FROM [Articles] WHERE [Date] = '20030104' Sql server will always recognize 'YYYYMMDD' regardless of your locale setting. Of course it's just easier to use a Command object and pass the date as a parameter and let the provider worry about the right format. Jerry field
Hi Martin, Default format for SQL Server is MM/DD/YYYY and you need to enclose your date into single quotes. You also should be aware that Date is a reserved word and you need to wrap all reserved words into square brackets Select [Date] from Articles where [Date]='01/04/2003' -- Val Mazur Microsoft MVP Check Virus Alert, stay updated http://www.**--****.com/ field
Users browsing this forum: No registered users and 89 guest