June 9, 2008 at 7:35 am
Hi,
I wanted to retrive the records from the data base between two dates selected from 2 calendars.
The date format is in uk standard.Can any one please send me the solution for this?Thanks in advance.
Regards,
Pallavi.
June 9, 2008 at 10:25 am
I presume that the date in DB is in string format.
Please refer to the following code:
Declare @FromDate Varchar(10)
Declare @ToDate Varchar(10)
Set @FromDate = '1/5/2008'
Set @ToDate = '31/7/2008'
Create table #TT
(
ID Int,
Date Varchar(20)
)
Insert Into #TT
Select 1, '10/5/2008'
Union
Select 2, '5/10/2008'
Union
Select 3, '31/7/2008'
select * From #TT
Where convert(datetime,Date,103) BetWeen convert(datetime,@FromDate,103) And convert(datetime,@ToDate,103)
Change this code to use your table and i guess you will be OK. The convert with 103 will convert the string to British format date.
Hope it works!
June 10, 2008 at 2:48 am
Hi,
Thank you very much for your reply.I used that code ,it works fine.I amso happy.
Regards,
Pallavi.
July 6, 2008 at 11:12 pm
pallavikiran.deevi (6/10/2008)
Hi,Thank you very much for your reply.I used that code ,it works fine.I amso happy.
Regards,
Pallavi.
It would be better, in the long run, to change the Date column in the table to a DateTime datatype.
--Jeff Moden
Change is inevitable... Change for the better is not.
July 10, 2008 at 7:17 am
Thanks 🙂
Abhay Jain
Swastik Info solutions
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply