473,748 Members | 2,328 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataTable.Selec t condition with TimeSpan Values

Hi to All,
i'm using C# in .NET 2.0 and i have a DataTable A with a column of
type TimeSpan used to store HOUR info.
I'm trying to filter my DataTable A selecting only rows that have the
column HOUR ....

if i try to Call A.Select( " HOUR '10:30:00' " ) i receive an error
( cannot compare TimeSpan with String ...)
if i try to call A.Select ( " HOUR 10:30:00 " ) i receive an error
( invalid token : )
if i try to call A.Select ( " HOUR >
Convert('10:30: 00',System.Time Span) " ) i receive an error ( string
'10:00:00' is not a valid TimeSpan )

if i try to call A.Select ( " HOUR #10:30:00#" ) i receive an error
( Cannot compare TimeSpan with Date )

....
....
i think that i missed only the right way to write my filter.
Can someone help me?

Thank you in advance.

Regards,

Massimo

Jul 9 '07 #1
4 6251

"Massimo" <ma***********@ tiscali.itwrote in message
news:11******** **************@ n60g2000hse.goo glegroups.com.. .
Hi to All,
i'm using C# in .NET 2.0 and i have a DataTable A with a column of
type TimeSpan used to store HOUR info.
I'm trying to filter my DataTable A selecting only rows that have the
column HOUR ....

if i try to Call A.Select( " HOUR '10:30:00' " ) i receive an error
( cannot compare TimeSpan with String ...)
if i try to call A.Select ( " HOUR 10:30:00 " ) i receive an error
( invalid token : )
if i try to call A.Select ( " HOUR >
Convert('10:30: 00',System.Time Span) " ) i receive an error ( string
'10:00:00' is not a valid TimeSpan )

if i try to call A.Select ( " HOUR #10:30:00#" ) i receive an error
( Cannot compare TimeSpan with Date )

...
...
i think that i missed only the right way to write my filter.
Can someone help me?
Not really, as a matter of fact I think that you cannot use it. HOUR is of
type TimeSpan, and unless it define a comparision with an integer (I do not
think so) you cannot use select.

What if you isntead of using TimeSpan use an integer to just hold the hours?
then it will be an integer and you will be able to use Select
Jul 9 '07 #2
On 9 Lug, 16:53, "Ignacio Machin \( .NET/ C# MVP \)" <machin TA
laceupsolutions .comwrote:
"Massimo" <massimo.fr...@ tiscali.itwrote in message

news:11******** **************@ n60g2000hse.goo glegroups.com.. .


Hi to All,
i'm using C# in .NET 2.0 and i have a DataTable A with a column of
type TimeSpan used to store HOUR info.
I'm trying to filter my DataTable A selecting only rows that have the
column HOUR ....
if i try to Call A.Select( " HOUR '10:30:00' " ) i receive an error
( cannot compare TimeSpan with String ...)
if i try to call A.Select ( " HOUR 10:30:00 " ) i receive an error
( invalid token : )
if i try to call A.Select ( " HOUR >
Convert('10:30: 00',System.Time Span) " ) i receive an error ( string
'10:00:00' is not a valid TimeSpan )
if i try to call A.Select ( " HOUR #10:30:00#" ) i receive an error
( Cannot compare TimeSpan with Date )
...
...
i think that i missed only the right way to write my filter.
Can someone help me?

Not really, as a matter of fact I think that you cannot use it. HOUR is of
type TimeSpan, and unless it define a comparision with an integer (I do not
think so) you cannot use select.

What if you isntead of using TimeSpan use an integer to just hold the hours?
then it will be an integer and you will be able to use Select- Nascondi testo tra virgolette -

- Mostra testo tra virgolette -
i could create a conversion between a TimeSpan ( i.e. 10:35:20 ) into
an integer 1035,20 but tell me , why i don't read restrictions of any
type about timeSpan values into MSDN ?
i'm confident that exists ( and, if not , will ...) a way to use
Select with Timespan comparison or, at least a special char like # for
Dates to convert strings in timespan.
I cannot beleave that i'm the first to use Select method with timespan
params...
In any case, thank you

Massimo

Jul 9 '07 #3
Hi,

"Massimo" <ma***********@ tiscali.itwrote in message
news:11******** *************@n 60g2000hse.goog legroups.com...
On 9 Lug, 16:53, "Ignacio Machin \( .NET/ C# MVP \)" <machin TA
laceupsolutions .comwrote:
>"Massimo" <massimo.fr...@ tiscali.itwrote in message

news:11******* *************** @n60g2000hse.go oglegroups.com. ..


Hi to All,
i'm using C# in .NET 2.0 and i have a DataTable A with a column of
type TimeSpan used to store HOUR info.
I'm trying to filter my DataTable A selecting only rows that have the
column HOUR ....
if i try to Call A.Select( " HOUR '10:30:00' " ) i receive an error
( cannot compare TimeSpan with String ...)
if i try to call A.Select ( " HOUR 10:30:00 " ) i receive an error
( invalid token : )
if i try to call A.Select ( " HOUR >
Convert('10:30: 00',System.Time Span) " ) i receive an error ( string
'10:00:00' is not a valid TimeSpan )
if i try to call A.Select ( " HOUR #10:30:00#" ) i receive an error
( Cannot compare TimeSpan with Date )
...
...
i think that i missed only the right way to write my filter.
Can someone help me?

Not really, as a matter of fact I think that you cannot use it. HOUR is
of
type TimeSpan, and unless it define a comparision with an integer (I do
not
think so) you cannot use select.

What if you isntead of using TimeSpan use an integer to just hold the
hours?
then it will be an integer and you will be able to use Select- Nascondi
testo tra virgolette -

- Mostra testo tra virgolette -

i could create a conversion between a TimeSpan ( i.e. 10:35:20 ) into
an integer 1035,20 but tell me , why i don't read restrictions of any
type about timeSpan values into MSDN ?
This is not a problem related to TimeSpan, it's more related to the way
Select works, Select just do a comparison between the value of the column
and the value provided, as TimeSpan do not provide conversion from either
string nor integer you cannot do it.

i'm confident that exists ( and, if not , will ...) a way to use
Select with Timespan comparison or, at least a special char like # for
Dates to convert strings in timespan.
I do not think so, but in case you find it post back your solution
Jul 9 '07 #4
On 9 Lug, 17:27, "Ignacio Machin \( .NET/ C# MVP \)" <machin TA
laceupsolutions .comwrote:
Hi,

"Massimo" <massimo.fr...@ tiscali.itwrote in message

news:11******** *************@n 60g2000hse.goog legroups.com...


On 9 Lug, 16:53, "Ignacio Machin \( .NET/ C# MVP \)" <machin TA
laceupsolutions .comwrote:
"Massimo" <massimo.fr...@ tiscali.itwrote in message
>news:11******* *************** @n60g2000hse.go oglegroups.com. ..
Hi to All,
i'm using C# in .NET 2.0 and i have a DataTable A with a column of
type TimeSpan used to store HOUR info.
I'm trying to filter my DataTable A selecting only rows that have the
column HOUR ....
if i try to Call A.Select( " HOUR '10:30:00' " ) i receive an error
( cannot compare TimeSpan with String ...)
if i try to call A.Select ( " HOUR 10:30:00 " ) i receive an error
( invalid token : )
if i try to call A.Select ( " HOUR >
Convert('10:30: 00',System.Time Span) " ) i receive an error ( string
'10:00:00' is not a valid TimeSpan )
if i try to call A.Select ( " HOUR #10:30:00#" ) i receive an error
( Cannot compare TimeSpan with Date )
...
...
i think that i missed only the right way to write my filter.
Can someone help me?
Not really, as a matter of fact I think that you cannot use it. HOUR is
of
type TimeSpan, and unless it define a comparision with an integer (I do
not
think so) you cannot use select.
What if you isntead of using TimeSpan use an integer to just hold the
hours?
then it will be an integer and you will be able to use Select- Nascondi
testo tra virgolette -
- Mostra testo tra virgolette -
i could create a conversion between a TimeSpan ( i.e. 10:35:20 ) into
an integer 1035,20 but tell me , why i don't read restrictions of any
type about timeSpan values into MSDN ?

This is not a problem related to TimeSpan, it's more related to the way
Select works, Select just do a comparison between the value of the column
and the value provided, as TimeSpan do not provide conversion from either
string nor integer you cannot do it.
i'm confident that exists ( and, if not , will ...) a way to use
Select with Timespan comparison or, at least a special char like # for
Dates to convert strings in timespan.

I do not think so, but in case you find it post back your solution- Nascondi testo tra virgolette -

- Mostra testo tra virgolette -
OK,

into the MSDN Page related to DataTable.Selec t method there is an
example :

expression = "Date '1/1/00'";

in this case the value is a String but i expect that the filter
compares two dates. i find strange that is non possible to do the same
thing with an hour instead a Date...



Jul 9 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2253
by: randy | last post by:
Hello all, I have a DataTable which I am building column by column and adding rows after each new column. The DataTable columns match the columns in my database table. I'm building the DataTable first and I then want to roll through the DataTable while in memory checking for errors and then commit the rows to my database table (btw this is in ASP.NET). Is it possible to have data in a datable before attaching at DataAdapter? I'm a...
6
17446
by: Millo | last post by:
Hi I'm trying to call the method Contains in a loop: out of the loop I set the primary key of the dataTable. The method returns true one time at a certani value, but then, when the loop steps forward to check another value, the method returns false, although the value is contained in the dataTable (DateTime values). So the loop goes and goes ...
11
9724
by: Russ Green | last post by:
How does this: public TimeSpan Timeout { get { return timeout; } set { timeout = value; if(timeout < licenseTimeout) licenseTimeout = timeout; }
0
3157
by: Chris Ericoli | last post by:
Hi, I am working with an 'in session' ado dataset with an asp.net application. My dataset is comprised of two tables, one of which maintains a few calculated datacolumns. For some reason these datacolumns do not trigger their expression when other columns from which the expressions are derived are updated. Below is a basic example of what I am doing. User enters values into an asp.net form and clicks a button. Retrieve dataset from...
2
1251
by: deko | last post by:
This is something of a design question. I have WinForms app that requires persisting a bunch of user settings. The app maintains a number of "Projects" that contain a variety of parameters, many of which are Array objects. Can I store all these things in a DataTable and just serialize/deserialize the DataTable to XML when the app starts? What is the best way to persist user settings?
22
12486
by: MP | last post by:
vb6,ado,mdb,win2k i pass the sql string to the .Execute method on the open connection to Table_Name(const) db table fwiw (the connection opened via class wrapper:) msConnString = "Data Source=" & msDbFilename moConn.Properties("Persist Security Info") = False moConn.ConnectionString = msConnString moConn.CursorLocation = adUseClient moConn.Mode = adModeReadWrite' or using default...same result
0
3516
by: Screaming Eagles 101 | last post by:
Not sure in which group to post, sorry... We are using VB2005 on Windows XP. After getting my data in a datatable and parse it to a recordset according to the method on http://www.codeproject.com/cs/database/DataTableToRecordset.asp , which learned us to convert an ADO.Net datatable to an ADODB.Recordset, needed by the Microsoft Office Spreadsheet Web Component (OWC11), we got an error on the checking of a TIME column.
1
2644
by: Ryan Liu | last post by:
Hi, I read a csv file to a datatable. I don't know what are the column types at this moment, so I treat all columns as string type. After I read data from file, I use dataTable.Select(condition) to select some lines. The problem is with numeric columns, since in datatable, it is string type, it compares rows as string so make Select() return wrong set of rows.
2
4414
by: senglory | last post by:
My WCF: public interface IWorkbookService { DataTable GetDownpayments(KeyValuePair<int, string> sgm); } class WorkbookService : IWorkbookService
0
9528
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9359
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9236
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8235
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6072
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4592
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3298
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2774
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2206
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.