Date format is dd/mm/yyyy and not able to apply between query on that format

Posted by Navi1478 under Sql Server on 6/10/2013 | Points: 10 | Views : 1084 | Status : [Member] | Replies : 2
In My database date format is dd/mm/yyyy and not able to apply between query on that format

1)select * from tbstd_rec where joiningdate between '1/6/2013' and '10/6/2013'

Get all record where 1/6 -10/6 exists either in 2009,2010 record ..Very vast database and not able to edit datetime format ..please help me




Responses

Posted by: Neeraaj.Sharma on: 6/24/2013 [Member] Starter | Points: 25

Up
0
Down
please let us know your data type is i guess it is varchar if it is then
convert it to datetime and then quesry again.

select * from tbstd_rec where Convert(datetime ,joiningdate) between '1/6/2013' and '10/6/2013'

if this does`t help please re create a scenario here by creating and tempory table here and put some data.





visit my blog http://www.tutorialsqlserver.com/




Navi1478, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bageshkumarbagi on: 6/24/2013 [Member] Starter | Points: 25

Up
0
Down
Hi,

select * from tbstd_rec where CONVERT ( DATETIME , Joiningdate( '1/6/2013' ) between '1/6/2013' and '10/6/2013'


Thanks,
Bagesh Kumar Singh




Thanks,
Bagesh Kumar Singh
Mark as answer if you have been satisfied

Navi1478, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response