Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How to Select records from database where date format is dd/MM/yyyy.

Example I want all records where Start date >= '30/11/2013'. Since currently format of date in sql is MM/dd/yyyy
Posted

http://www.sql-server-helper.com/sql-server-2008/sql-server-2008-date-format.aspx[^]


SELECT CONVERT(VARCHAR(8), SYSDATETIME(), 3) AS [DD/MM/YY]
 
Share this answer
 
v2
Comments
[no name] 7-Nov-13 6:18am    
I tried this but didn't work, It returned results from august where I picked date in September.Below my query:

Select * From TableName Where convert(datetime, myDate, 103) >= '03/09/2013'

my date format is dd/MM/yyyy
kankeyan 7-Nov-13 6:25am    
use
select @date= urstoreddate
Select * From TableName Where convert(datetime, myDate, 103) >= convert(datetime, @date, 103)
--'03/09/2013'
[no name] 7-Nov-13 7:44am    
Waw that works thanks a lot :)
CAST and CONVERT[^] should help you convert datetime frim one format to another.
Just run the query with appropriate conditions once done.
 
Share this answer
 
Comments
[no name] 7-Nov-13 6:15am    
I tried this but didn't work, It returned results from august where I picked date in September.Below my query:

Select * From TableName Where convert(datetime, myDate, 103) >= '03/09/2013'

my date format is dd/MM/yyyy
Abhinav S 7-Nov-13 6:21am    
If myDate is already in dd/mm/yyyy format then you need not use convert.
Thanks7872 7-Nov-13 7:34am    
Please use reply button while making comment otherwise OP won't get notification.
[no name] 7-Nov-13 7:48am    
I tried as you said and removed the convert but it still returned results from august:

The example:

Select * From TableName Where myDate >= '03/09/2013'

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900