|
|
Question : Date Problems
|
|
Hi,
I have a recordset in Dreamwever which asks a database to reurn all receords WHERE endDate is between todays date, and 40 days time. Here is the sql in the recordset:
SELECT * FROM tblContract WHERE contractEnd BETWEEN #nowDate# AND #xDate# ORDER BY contractEnd ASC
nowDate: runtume: Date() xDate: runtime:
Unfortunatly the recordset is returning all dates between 12/02/02 and todays date - Random
If anyone has any ideas as tto how to put this right, i would be most greatful.
thanks in advance
Paul
|
Answer : Date Problems
|
|
I think it depends on where you come from, access only reads American format, i.e. mm/dd/yyyy. The first thing to do is set up your dates to read mm/dd/yyyy as follows:
<% Session.LCID = 2064 fromdate = date todate = date+40 intTODate = TODATE intFROMDate = FROMDATE intTODay = Day(intTODate) intTOMonth = Month(intTODate) intTOYear = Year(intTODate) if Len(intTODay)=1 Then intTODay = "0" & intTODay if Len(intTOMonth)=1 Then intTOMonth = "0" & intTOMonth if Len(intTOYear)=4 Then intTOYear = Right(intTOYear, 2) intFROMDay = Day(intFROMDate) intFROMMonth = Month(intFROMDate) intFROMYear = Year(intFROMDate) if Len(intFROMDay)=1 Then intFROMDay = "0" & intFROMDay if Len(intFROMMonth)=1 Then intFROMMonth = "0" & intFROMMonth if Len(intFROMYear)=4 Then intFROMYear = Right(intFROMYear, 2) nowdate = ( IntFROMMonth& "/" & IntFROMDay & "/" & IntFROMYear) xdate = (IntTOMonth & "/" & IntTODay & "/" & IntTOYear) %>
Now your dates are in the correct format for reading access databases
Now lets read the database
<% Session.LCID = 1033 %> <% SELECT * FROM tblContract WHERE WHERE contractEnd BETWEEN #nowDate# AND #xDate# ORDER BY contractEnd ASC %>
Try it and see if it works, as I said I am not sure where you come from, but I being Irish have this problem a lot and the above code fixes it.
|
|
|
|
|