Hello All,
I am running Win XP pro as a standalone PC, with Office XP (Access 2002) installed. I live in Australia and as such set my default date preferences to the Aust. standard of dd/mm/yyyy (as opposed to mm/dd/yyyy), when I installed Windows.
Recently I installed XP SP2 which appears to have set back my windows default preferences to the US mm/dd/yyyy standard. I developed my database from scratch over the last three weeks on this platform and I assumed that the Access environment dictated that I must use the US date format.
It was only today that I investigated my windows settings, and discovered they had reverted back to the US settings.
After changing the locale etc back to Australia, and a reeboot all seemed fine, except I noticed that my queries would not pick up a specific date.
I'll embelish a little on my stored dates.
<beginEmbilish>
My db imports a weekly (sales) file downloaded from a 3rd party off the internet. Every Thursday they update their weekly report, such that a report downloaded on a thursday will be for the week ending 3 days prior to that thursday. A report downloaded on the Friday thru to the following Wednesday will be the same file, hence the date is is stored in the db must be the same.
</endEmbelish>
Anywho, my (VBA) function which works all of this out for me was working like a charm.... until I changed my system settings to dd/mm/yyyy.
Here is the code for my function:
Now, all was good until the change. Afterwards, strange things started happening. My function continued to work fine except for when the dd and mm had the same value (ie 11/11/2004, 12/12/2004) When they fit the " dd == mm " criterion they, (after being processed by my function), turned into the US date format. ie Thursday 11th November should have returned 07/11/2004 (7th November 2004), instead it returned 11/07/2004 (11th July 2004)!
Part of my embedded SQL (Jet) relies on these dates and the queries are sometimes running and returning no records (none exist for the false/backward range), or else the query which stores the SQL is coming up with an SQL error, essentially truncating the SQL statement halfway through.
If however, I select the 'bad' dates, run a debug.print, copy and paste the resultant sql into a new query window and change the date fields to the correct values in the dd/mm/yyyy format then all is well.
I assume that my problem lies with the inbuilt function " DateAdd" (Note: I am passing it a -ve value to subtract a certain number of days).
Does anyone else know of any alternatives, or how I might go about coding one up for myself? -- I had thoughts of coding my own one before I found the 'DateAdd' function, and the prospect did not appeal to me that much ;D
Sorry about the length of this submission (READ: Ramble), all thoughts and suggestions are appreciated. -- In any case, I have to find a solution, so if none are forthcoming, i'll keep this space posted.
Thanks -- blakey2.
I am running Win XP pro as a standalone PC, with Office XP (Access 2002) installed. I live in Australia and as such set my default date preferences to the Aust. standard of dd/mm/yyyy (as opposed to mm/dd/yyyy), when I installed Windows.
Recently I installed XP SP2 which appears to have set back my windows default preferences to the US mm/dd/yyyy standard. I developed my database from scratch over the last three weeks on this platform and I assumed that the Access environment dictated that I must use the US date format.
It was only today that I investigated my windows settings, and discovered they had reverted back to the US settings.
After changing the locale etc back to Australia, and a reeboot all seemed fine, except I noticed that my queries would not pick up a specific date.
I'll embelish a little on my stored dates.
<beginEmbilish>
My db imports a weekly (sales) file downloaded from a 3rd party off the internet. Every Thursday they update their weekly report, such that a report downloaded on a thursday will be for the week ending 3 days prior to that thursday. A report downloaded on the Friday thru to the following Wednesday will be the same file, hence the date is is stored in the db must be the same.
</endEmbelish>
Anywho, my (VBA) function which works all of this out for me was working like a charm.... until I changed my system settings to dd/mm/yyyy.
Here is the code for my function:
Code:
Public Function establishWeekEnding() As String
Dim today As Integer
' Set variable 'today' to the numeric value as a weekday
' i.e. Sun = 1, Mon = 2... Sat = 7, Sun = 1... etc
today = DatePart("w", Date)
Select Case today
Case 1 'Sunday
establishWeekEnding = DateAdd("d", -7, Date)
Case 2 'Monday
establishWeekEnding = DateAdd("d", -8, Date)
Case 3 'Tuesday
establishWeekEnding = DateAdd("d", -9, Date)
Case 4 'Wednesday
establishWeekEnding = DateAdd("d", -10, Date)
Case 5 'Thursday -- NEW WEEK REPORT COMES OUT!
establishWeekEnding = DateAdd("d", -4, Date)
Case 6 'Friday
establishWeekEnding = DateAdd("d", -5, Date)
Case 7 'Saturday
establishWeekEnding = DateAdd("d", -6, Date)
End Select
End Function
Now, all was good until the change. Afterwards, strange things started happening. My function continued to work fine except for when the dd and mm had the same value (ie 11/11/2004, 12/12/2004) When they fit the " dd == mm " criterion they, (after being processed by my function), turned into the US date format. ie Thursday 11th November should have returned 07/11/2004 (7th November 2004), instead it returned 11/07/2004 (11th July 2004)!
Part of my embedded SQL (Jet) relies on these dates and the queries are sometimes running and returning no records (none exist for the false/backward range), or else the query which stores the SQL is coming up with an SQL error, essentially truncating the SQL statement halfway through.
If however, I select the 'bad' dates, run a debug.print, copy and paste the resultant sql into a new query window and change the date fields to the correct values in the dd/mm/yyyy format then all is well.
I assume that my problem lies with the inbuilt function " DateAdd" (Note: I am passing it a -ve value to subtract a certain number of days).
Does anyone else know of any alternatives, or how I might go about coding one up for myself? -- I had thoughts of coding my own one before I found the 'DateAdd' function, and the prospect did not appeal to me that much ;D
Sorry about the length of this submission (READ: Ramble), all thoughts and suggestions are appreciated. -- In any case, I have to find a solution, so if none are forthcoming, i'll keep this space posted.
Thanks -- blakey2.