Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > [Newbie UK Date problem] Ways atround this UK date format localisation/SQLselection issue?

Reply
Thread Tools

[Newbie UK Date problem] Ways atround this UK date format localisation/SQLselection issue?

 
 
DC
Guest
Posts: n/a
 
      07-01-2005
Im having a rather annoying SQL related problem with SELECT statemnets
and UK dates

The entire application is globalised to culture="en-GB" and
uiCulture="en-GB", and the access database is displaying and accepting
dates in UK format.

For some reason the statement is selecting the records with a date
before rather than after dtCurrDate.

dtCurrDate is produced via DateTime.Now and appears to be returning the
correct current date in uk format.

"SELECT * From SeminarList WHERE SeminarDate > #" + dtCurrDate +"# ORDER
BY SeminarDate";

Produces a set of records where SeminarDate is before todays date. Is
there something else I need to change?

EG: today the SQL produced was

SELECT * From SeminarList WHERE SeminarDate > #01/07/2005 00:00:00#
ORDER BY SeminarDate

and yet the diplay returns

Next Seminar - MSc dissertation presentations 2005
On 28/06/2005 at 11:30 in Sutcliffe Lecture Theatre (GU01)

Which obviously happened last week, is this a simple consequence of SQL
being inherantly US date formatted? Is there anything I can do about it?

--
_______________________________________________

DC

"You can not reason a man out of a position he did not reach through reason"

"Don't use a big word where a diminutive one will suffice."

"A man with a watch knows what time it is. A man with two watches is
never sure." Segal's Law

 
Reply With Quote
 
 
 
 
yer darn tootin
Guest
Posts: n/a
 
      07-01-2005
Try a sql CONVERT function on the date field in the query


SELECT * From SeminarList WHERE
CONVERT(varchar(12),SeminarDate,106) > '01/07/2005'
ORDER BY SeminarDate

 
Reply With Quote
 
 
 
 
yer darn tootin
Guest
Posts: n/a
 
      07-01-2005
Sorry, just noticed you wrote it was an ACCESS db - my answer was for
SQL server. Not sure if Access has any convert functions available.

 
Reply With Quote
 
Nick Malik [Microsoft]
Guest
Posts: n/a
 
      07-01-2005
I think that the SQL language in Access assumes US date order: mm/dd/yyyy

try this: convert your date string to use the USA format for the Select
statement. The rest should work as is.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"DC" <> wrote in message
news:da356g$ert$...
> Im having a rather annoying SQL related problem with SELECT statemnets and
> UK dates
>
> The entire application is globalised to culture="en-GB" and
> uiCulture="en-GB", and the access database is displaying and accepting
> dates in UK format.
>
> For some reason the statement is selecting the records with a date before
> rather than after dtCurrDate.
>
> dtCurrDate is produced via DateTime.Now and appears to be returning the
> correct current date in uk format.
>
> "SELECT * From SeminarList WHERE SeminarDate > #" + dtCurrDate +"# ORDER
> BY SeminarDate";
>
> Produces a set of records where SeminarDate is before todays date. Is
> there something else I need to change?
>
> EG: today the SQL produced was
>
> SELECT * From SeminarList WHERE SeminarDate > #01/07/2005 00:00:00# ORDER
> BY SeminarDate
>
> and yet the diplay returns
>
> Next Seminar - MSc dissertation presentations 2005
> On 28/06/2005 at 11:30 in Sutcliffe Lecture Theatre (GU01)
>
> Which obviously happened last week, is this a simple consequence of SQL
> being inherantly US date formatted? Is there anything I can do about it?
>
> --
> _______________________________________________
>
> DC
>
> "You can not reason a man out of a position he did not reach through
> reason"
>
> "Don't use a big word where a diminutive one will suffice."
>
> "A man with a watch knows what time it is. A man with two watches is never
> sure." Segal's Law
>



 
Reply With Quote
 
Christof Nordiek
Guest
Posts: n/a
 
      07-01-2005
Hi DC

instead of pasting your value into the SQL-Statement you should use
parameters.
Then the Dataprovider does all the convertion for you in the right way.
By that, you also can prevent SQL-injection attacks.

But I don't know if that's possible with Access.

Christof

"DC" <> schrieb im Newsbeitrag
news:da356g$ert$...
> Im having a rather annoying SQL related problem with SELECT statemnets and
> UK dates
>
> The entire application is globalised to culture="en-GB" and
> uiCulture="en-GB", and the access database is displaying and accepting
> dates in UK format.
>
> For some reason the statement is selecting the records with a date before
> rather than after dtCurrDate.
>
> dtCurrDate is produced via DateTime.Now and appears to be returning the
> correct current date in uk format.
>
> "SELECT * From SeminarList WHERE SeminarDate > #" + dtCurrDate +"# ORDER
> BY SeminarDate";
>
> Produces a set of records where SeminarDate is before todays date. Is
> there something else I need to change?
>
> EG: today the SQL produced was
>
> SELECT * From SeminarList WHERE SeminarDate > #01/07/2005 00:00:00# ORDER
> BY SeminarDate
>
> and yet the diplay returns
>
> Next Seminar - MSc dissertation presentations 2005
> On 28/06/2005 at 11:30 in Sutcliffe Lecture Theatre (GU01)
>
> Which obviously happened last week, is this a simple consequence of SQL
> being inherantly US date formatted? Is there anything I can do about it?
>
> --
> _______________________________________________
>
> DC
>
> "You can not reason a man out of a position he did not reach through
> reason"
>
> "Don't use a big word where a diminutive one will suffice."
>
> "A man with a watch knows what time it is. A man with two watches is never
> sure." Segal's Law
>



 
Reply With Quote
 
Brendan Reynolds
Guest
Posts: n/a
 
      07-01-2005
See the following on-line help topic ...
http://office.microsoft.com/assistan...HP010322871033

In particular, see the paragraph beginning ...

"When you specify the criteria argument, date literals must be in U.S.
format, even if you are not using the U.S. version of the Microsoft® Jet
database engine."

--
Brendan Reynolds (Access MVP)

"DC" <> wrote in message
news:da356g$ert$...
> Im having a rather annoying SQL related problem with SELECT statemnets and
> UK dates
>
> The entire application is globalised to culture="en-GB" and
> uiCulture="en-GB", and the access database is displaying and accepting
> dates in UK format.
>
> For some reason the statement is selecting the records with a date before
> rather than after dtCurrDate.
>
> dtCurrDate is produced via DateTime.Now and appears to be returning the
> correct current date in uk format.
>
> "SELECT * From SeminarList WHERE SeminarDate > #" + dtCurrDate +"# ORDER
> BY SeminarDate";
>
> Produces a set of records where SeminarDate is before todays date. Is
> there something else I need to change?
>
> EG: today the SQL produced was
>
> SELECT * From SeminarList WHERE SeminarDate > #01/07/2005 00:00:00# ORDER
> BY SeminarDate
>
> and yet the diplay returns
>
> Next Seminar - MSc dissertation presentations 2005
> On 28/06/2005 at 11:30 in Sutcliffe Lecture Theatre (GU01)
>
> Which obviously happened last week, is this a simple consequence of SQL
> being inherantly US date formatted? Is there anything I can do about it?
>
> --
> _______________________________________________
>
> DC
>
> "You can not reason a man out of a position he did not reach through
> reason"
>
> "Don't use a big word where a diminutive one will suffice."
>
> "A man with a watch knows what time it is. A man with two watches is never
> sure." Segal's Law
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Two ways to Converter DVD to iPod MP4 Format Jukiss Software 9 09-15-2009 04:14 AM
Culter + Date Format in MM/DD/YYYY Database - how to force a single format? Chu ASP .Net 3 08-15-2006 09:42 PM
Any quick ways to date stamp the Back my Photo's? lbbss Digital Photography 7 06-30-2005 04:13 PM
Date, date date date.... Peter Grison Java 10 05-30-2004 01:20 PM
Date Format - best way of converting a string into a date format Brian Candy ASP .Net 2 02-18-2004 02:13 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57