By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,212 Members | 1,110 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,212 IT Pros & Developers. It's quick & easy.

Filter datatable on date field on server pc problem

P: n/a
Hi,

i have a client program that sends a filter expression to the server PC. On
that server PC this filter is put over a datatable and the result is send
back.

the server can be located on a PC with let's say ddmmyyyy windows date
format and the client has mmddyyyy.

when the filter expression send is "Date < #31/01/2003#", it will fail on
the server because the format for day and month is different.

is there a generic way to send a filter expression used with the
DataTable.Select command so that it works always whatever the windows
setting is?

or should i get the default windows date format from the server, send it to
the client which it should use?

thanks.
Nov 15 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Hi Willie,

IF you cannot control the way that each part of the application you then
need to transform it on something generic, like a Tick, can you send the
data from the client to the server as a Tick ( this is defined as long ) ?
If so you could do this in the client:
DateTime.Ticks

and in the server:
new DateTime( tickCount )

in this way you don't care how the datetime is represented on the client or
on the server.

Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Willie wjb" <wj****@nomail.nl> wrote in message
news:uY**************@TK2MSFTNGP11.phx.gbl...
Hi,

i have a client program that sends a filter expression to the server PC. On that server PC this filter is put over a datatable and the result is send
back.

the server can be located on a PC with let's say ddmmyyyy windows date
format and the client has mmddyyyy.

when the filter expression send is "Date < #31/01/2003#", it will fail on
the server because the format for day and month is different.

is there a generic way to send a filter expression used with the
DataTable.Select command so that it works always whatever the windows
setting is?

or should i get the default windows date format from the server, send it to the client which it should use?

thanks.

Nov 15 '05 #2

P: n/a
the problem i have is that the client program is a sdk. So each user can
define it own where clauses...

does anybody know if the date format used by ado.net is restricted to US
format MM/dd/yyyy hh:mm:ss

i am doing several tests on different machines and found out that ado.net
only works with this US format, even on german pc's.

But when using i must be 100% sure that is behaves this way, and i can not
find any info for this on msdn.
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:uH**************@TK2MSFTNGP11.phx.gbl...
Hi Willie,

IF you cannot control the way that each part of the application you then
need to transform it on something generic, like a Tick, can you send the
data from the client to the server as a Tick ( this is defined as long ) ?
If so you could do this in the client:
DateTime.Ticks

and in the server:
new DateTime( tickCount )

in this way you don't care how the datetime is represented on the client or on the server.

Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Willie wjb" <wj****@nomail.nl> wrote in message
news:uY**************@TK2MSFTNGP11.phx.gbl...
Hi,

i have a client program that sends a filter expression to the server PC.

On
that server PC this filter is put over a datatable and the result is send back.

the server can be located on a PC with let's say ddmmyyyy windows date
format and the client has mmddyyyy.

when the filter expression send is "Date < #31/01/2003#", it will fail on the server because the format for day and month is different.

is there a generic way to send a filter expression used with the
DataTable.Select command so that it works always whatever the windows
setting is?

or should i get the default windows date format from the server, send it

to
the client which it should use?

thanks.


Nov 15 '05 #3

P: n/a

"Willie wjb" <wj****@nomail.nl> wrote in message
news:u7**************@TK2MSFTNGP11.phx.gbl...
the problem i have is that the client program is a sdk. So each user can
define it own where clauses...

does anybody know if the date format used by ado.net is restricted to US
format MM/dd/yyyy hh:mm:ss
For jet sql data litereals #...# must always be in US format.

i am doing several tests on different machines and found out that ado.net
only works with this US format, even on german pc's.
You can use the function DateValue which is aware of international settings
in windows :

"SELECT * FROM tblTest WHERE test > DateValue('12/3/03')"

Hope this helps
greetings

But when using i must be 100% sure that is behaves this way, and i can not
find any info for this on msdn.
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote in message news:uH**************@TK2MSFTNGP11.phx.gbl...
Hi Willie,

IF you cannot control the way that each part of the application you then
need to transform it on something generic, like a Tick, can you send the
data from the client to the server as a Tick ( this is defined as long ) ? If so you could do this in the client:
DateTime.Ticks

and in the server:
new DateTime( tickCount )

in this way you don't care how the datetime is represented on the client

or
on the server.

Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Willie wjb" <wj****@nomail.nl> wrote in message
news:uY**************@TK2MSFTNGP11.phx.gbl...
Hi,

i have a client program that sends a filter expression to the server
PC. On
that server PC this filter is put over a datatable and the result is send back.

the server can be located on a PC with let's say ddmmyyyy windows date
format and the client has mmddyyyy.

when the filter expression send is "Date < #31/01/2003#", it will fail on the server because the format for day and month is different.

is there a generic way to send a filter expression used with the
DataTable.Select command so that it works always whatever the windows
setting is?

or should i get the default windows date format from the server, send

it to
the client which it should use?

thanks.



Nov 15 '05 #4

P: n/a
ado.net does not contain a DateValue function

i use the rowfilter on a datatable that is in memory, no jet or sql
connection.

"BMermuys" <bm**************@hotmail.com> wrote in message
news:%x*********************@phobos.telenet-ops.be...

"Willie wjb" <wj****@nomail.nl> wrote in message
news:u7**************@TK2MSFTNGP11.phx.gbl...
the problem i have is that the client program is a sdk. So each user can
define it own where clauses...

does anybody know if the date format used by ado.net is restricted to US
format MM/dd/yyyy hh:mm:ss
For jet sql data litereals #...# must always be in US format.

i am doing several tests on different machines and found out that ado.net
only works with this US format, even on german pc's.


You can use the function DateValue which is aware of international

settings in windows :

"SELECT * FROM tblTest WHERE test > DateValue('12/3/03')"

Hope this helps
greetings

But when using i must be 100% sure that is behaves this way, and i can not find any info for this on msdn.
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:uH**************@TK2MSFTNGP11.phx.gbl...
Hi Willie,

IF you cannot control the way that each part of the application you then need to transform it on something generic, like a Tick, can you send the data from the client to the server as a Tick ( this is defined as long ) ?
If so you could do this in the client:
DateTime.Ticks

and in the server:
new DateTime( tickCount )

in this way you don't care how the datetime is represented on the
client or
on the server.

Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Willie wjb" <wj****@nomail.nl> wrote in message
news:uY**************@TK2MSFTNGP11.phx.gbl...
> Hi,
>
> i have a client program that sends a filter expression to the server PC. On
> that server PC this filter is put over a datatable and the result is send
> back.
>
> the server can be located on a PC with let's say ddmmyyyy windows
date > format and the client has mmddyyyy.
>
> when the filter expression send is "Date < #31/01/2003#", it will fail on
> the server because the format for day and month is different.
>
> is there a generic way to send a filter expression used with the
> DataTable.Select command so that it works always whatever the

windows > setting is?
>
> or should i get the default windows date format from the server,

send it to
> the client which it should use?
>
> thanks.
>
>



Nov 15 '05 #5

P: n/a
Hi,
[inline]

"Willie wjb" <wj****@nomail.nl> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
ado.net does not contain a DateValue function

i use the rowfilter on a datatable that is in memory, no jet or sql
connection.
I don't know if this helps you much, but here are some conversions methods
that might give you some ideas As you already know, there is no way to
tell which format a date is in if the day is less or equal to 12. So
ussally the sender of the date converts the date to a fixed format or
specifies what the format is.

static string LocalToUS(string local)
{
System.Globalization.CultureInfo usc =
new System.Globalization.CultureInfo("en-US");

// default parsing uses current culture (local format)
DateTime dt = DateTime.Parse(local);

return dt.ToString(usc.DateTimeFormat.ShortDatePattern);
}

static string USToLocal(string us)
{
System.Globalization.CultureInfo usc =
new System.Globalization.CultureInfo("en-US");

DateTime dt = DateTime.Parse(us, usc);

return dt.ToString(System.Globalization.CultureInfo.
CurrentCulture.DateTimeFormat.ShortDatePattern);
}

Greetings


"BMermuys" <bm**************@hotmail.com> wrote in message
news:%x*********************@phobos.telenet-ops.be...

"Willie wjb" <wj****@nomail.nl> wrote in message
news:u7**************@TK2MSFTNGP11.phx.gbl...
the problem i have is that the client program is a sdk. So each user can define it own where clauses...

does anybody know if the date format used by ado.net is restricted to US format MM/dd/yyyy hh:mm:ss


For jet sql data litereals #...# must always be in US format.

i am doing several tests on different machines and found out that ado.net only works with this US format, even on german pc's.


You can use the function DateValue which is aware of international

settings
in windows :

"SELECT * FROM tblTest WHERE test > DateValue('12/3/03')"

Hope this helps
greetings

But when using i must be 100% sure that is behaves this way, and i can not find any info for this on msdn.
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us>

wrote
in message news:uH**************@TK2MSFTNGP11.phx.gbl...
> Hi Willie,
>
> IF you cannot control the way that each part of the application you

then
> need to transform it on something generic, like a Tick, can you send the > data from the client to the server as a Tick ( this is defined as long )
?
> If so you could do this in the client:
> DateTime.Ticks
>
> and in the server:
> new DateTime( tickCount )
>
> in this way you don't care how the datetime is represented on the client or
> on the server.
>
> Hope this help,
>
> --
> Ignacio Machin,
> ignacio.machin AT dot.state.fl.us
> Florida Department Of Transportation
>
> "Willie wjb" <wj****@nomail.nl> wrote in message
> news:uY**************@TK2MSFTNGP11.phx.gbl...
> > Hi,
> >
> > i have a client program that sends a filter expression to the server PC.
> On
> > that server PC this filter is put over a datatable and the result
is send
> > back.
> >
> > the server can be located on a PC with let's say ddmmyyyy windows

date > > format and the client has mmddyyyy.
> >
> > when the filter expression send is "Date < #31/01/2003#", it will fail on
> > the server because the format for day and month is different.
> >
> > is there a generic way to send a filter expression used with the
> > DataTable.Select command so that it works always whatever the windows > > setting is?
> >
> > or should i get the default windows date format from the server,

send
it
> to
> > the client which it should use?
> >
> > thanks.
> >
> >
>
>



Nov 15 '05 #6

P: n/a
this one also passed my mind.
turn the server application into a english by changing the culture for it,
and tell the clients to use always the english format.

Thanks for your help.

"BMermuys" <bm**************@hotmail.com> wrote in message
news:tq*********************@phobos.telenet-ops.be...
Hi,
[inline]

"Willie wjb" <wj****@nomail.nl> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
ado.net does not contain a DateValue function

i use the rowfilter on a datatable that is in memory, no jet or sql
connection.
I don't know if this helps you much, but here are some conversions methods
that might give you some ideas As you already know, there is no way to
tell which format a date is in if the day is less or equal to 12. So
ussally the sender of the date converts the date to a fixed format or
specifies what the format is.

static string LocalToUS(string local)
{
System.Globalization.CultureInfo usc =
new System.Globalization.CultureInfo("en-US");

// default parsing uses current culture (local format)
DateTime dt = DateTime.Parse(local);

return dt.ToString(usc.DateTimeFormat.ShortDatePattern);
}

static string USToLocal(string us)
{
System.Globalization.CultureInfo usc =
new System.Globalization.CultureInfo("en-US");

DateTime dt = DateTime.Parse(us, usc);

return dt.ToString(System.Globalization.CultureInfo.
CurrentCulture.DateTimeFormat.ShortDatePattern);
}

Greetings


"BMermuys" <bm**************@hotmail.com> wrote in message
news:%x*********************@phobos.telenet-ops.be...

"Willie wjb" <wj****@nomail.nl> wrote in message
news:u7**************@TK2MSFTNGP11.phx.gbl...
> the problem i have is that the client program is a sdk. So each user can > define it own where clauses...
>
> does anybody know if the date format used by ado.net is restricted to US
> format MM/dd/yyyy hh:mm:ss

For jet sql data litereals #...# must always be in US format.

>
> i am doing several tests on different machines and found out that ado.net
> only works with this US format, even on german pc's.

You can use the function DateValue which is aware of international

settings
in windows :

"SELECT * FROM tblTest WHERE test > DateValue('12/3/03')"

Hope this helps
greetings

>
> But when using i must be 100% sure that is behaves this way, and i
can
not
> find any info for this on msdn.
>
>
> "Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT
dot.state.fl.us> wrote
> in message news:uH**************@TK2MSFTNGP11.phx.gbl...
> > Hi Willie,
> >
> > IF you cannot control the way that each part of the application you then
> > need to transform it on something generic, like a Tick, can you

send the
> > data from the client to the server as a Tick ( this is defined as

long )
?
> > If so you could do this in the client:
> > DateTime.Ticks
> >
> > and in the server:
> > new DateTime( tickCount )
> >
> > in this way you don't care how the datetime is represented on the

client
> or
> > on the server.
> >
> > Hope this help,
> >
> > --
> > Ignacio Machin,
> > ignacio.machin AT dot.state.fl.us
> > Florida Department Of Transportation
> >
> > "Willie wjb" <wj****@nomail.nl> wrote in message
> > news:uY**************@TK2MSFTNGP11.phx.gbl...
> > > Hi,
> > >
> > > i have a client program that sends a filter expression to the server PC.
> > On
> > > that server PC this filter is put over a datatable and the
result is > send
> > > back.
> > >
> > > the server can be located on a PC with let's say ddmmyyyy

windows date
> > > format and the client has mmddyyyy.
> > >
> > > when the filter expression send is "Date < #31/01/2003#", it
will fail
> on
> > > the server because the format for day and month is different.
> > >
> > > is there a generic way to send a filter expression used with the
> > > DataTable.Select command so that it works always whatever the

windows
> > > setting is?
> > >
> > > or should i get the default windows date format from the server,

send
it
> > to
> > > the client which it should use?
> > >
> > > thanks.
> > >
> > >
> >
> >
>
>



Nov 15 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.