X
x-rays
Hello All,
I got a little problem with the data I want to fetch limited by a date
range.
What are my settings and what I use:
1) My regional settings are Greek and using the dd/mm/yyyy format for
dates (to be exact the short date format in my settings is d/M/yyyy)
2) I use Access 2003 (English Version) but my database is in Access
2000 Format
3) Windows XP SP2 (might be irrelevant but...)
In my tables, date is stored in dd/mm/yyyy format (because of regional
sets).
I have created 2 functions to return the first and the last date of the
year:
Function FirstDayOfTheYear_manual()
FirstDayOfTheYear_manual = DateSerial(Year(CVDate(Forms![Print
Reports]![Starting date])), 1, 1)
End Function
Function LastDayOfTheYear_manual()
LastDayOfTheYear_manual = DateSerial(Year(CVDate(Forms![Print
Reports]![Starting date])) + 1, 1, 1 - 1)
End Function
Now I create a simple Select query:
Select * from Table1 Where DateField between FirstDayOfTheYear_manual()
and LastDayOfTheYear_manual()
1st question:
I know that Access automaticaly changes the format of the dates in
mm/dd/yyyy for the where clauses but is it changes the format of the
DateField too?
2nd question:
Why this does not return any records:
Select * from Table1 Where Format(DateField, "mm/dd/yyyy") between
FirstDayOfTheYear_manual() and LastDayOfTheYear_manual()
I want this query to run in any system that uses english, greek,
chinese... any regional settings.
I got a little problem with the data I want to fetch limited by a date
range.
What are my settings and what I use:
1) My regional settings are Greek and using the dd/mm/yyyy format for
dates (to be exact the short date format in my settings is d/M/yyyy)
2) I use Access 2003 (English Version) but my database is in Access
2000 Format
3) Windows XP SP2 (might be irrelevant but...)
In my tables, date is stored in dd/mm/yyyy format (because of regional
sets).
I have created 2 functions to return the first and the last date of the
year:
Function FirstDayOfTheYear_manual()
FirstDayOfTheYear_manual = DateSerial(Year(CVDate(Forms![Print
Reports]![Starting date])), 1, 1)
End Function
Function LastDayOfTheYear_manual()
LastDayOfTheYear_manual = DateSerial(Year(CVDate(Forms![Print
Reports]![Starting date])) + 1, 1, 1 - 1)
End Function
Now I create a simple Select query:
Select * from Table1 Where DateField between FirstDayOfTheYear_manual()
and LastDayOfTheYear_manual()
1st question:
I know that Access automaticaly changes the format of the dates in
mm/dd/yyyy for the where clauses but is it changes the format of the
DateField too?
2nd question:
Why this does not return any records:
Select * from Table1 Where Format(DateField, "mm/dd/yyyy") between
FirstDayOfTheYear_manual() and LastDayOfTheYear_manual()
I want this query to run in any system that uses english, greek,
chinese... any regional settings.