473,382 Members | 1,545 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

truncate time from date in DataTable.Select()

I have a DataTable.Select() statement with a DateTime field that is
being compared to a Date:

Dim drCal as DataRow() = tblCal.Select("CalendarItemDate
='12/1/2003'", "CalendarItemDate", DataViewRowState.CurrentRows)

This never returns any rows because all the CalendarItemDate fields
that contain the date 12/1/2003 also contain a time component! I
searched until I was SICK and could not find how to truncate the time
from the DateTime field in the Select expression. :(

I would prefer to do it in the Select expression, but if I have to add
another field to the SQL statement that populates the DataSet, I guess
that will have to do. However, MS SQL 2000 no longer has the Trunc()
function!! I guess I have to use Round(n,0,1)??

Thanks in advance for any clues.

Cheers
Eddie
Nov 18 '05 #1
1 7833
Hi,

I don't normally set up a select like this, but you can try an old trick
like:

CalendarItemDate >= '12/1/2003 00:00:00' AND
CalendarItemDate <= '12/1/2003 23:59:59'

I'm surprised it's not working. Have you tried the select manually in Query
Analyzer? The select should match regardless of the time portion as long as
the date portion matches.

See the Transact-SQL help and look up the DatePart. You can use that to
construct a date-only value. Sorry I wasn't more helpful. I hope you get
it working, I know how frustrating this can be. Good luck.

--
Arthur
"Eddie" <ed********@yahoo.com> wrote in message
news:85**************************@posting.google.c om...
I have a DataTable.Select() statement with a DateTime field that is
being compared to a Date:

Dim drCal as DataRow() = tblCal.Select("CalendarItemDate
='12/1/2003'", "CalendarItemDate", DataViewRowState.CurrentRows)

This never returns any rows because all the CalendarItemDate fields
that contain the date 12/1/2003 also contain a time component! I
searched until I was SICK and could not find how to truncate the time
from the DateTime field in the Select expression. :(

I would prefer to do it in the Select expression, but if I have to add
another field to the SQL statement that populates the DataSet, I guess
that will have to do. However, MS SQL 2000 no longer has the Trunc()
function!! I guess I have to use Round(n,0,1)??

Thanks in advance for any clues.

Cheers
Eddie

Nov 18 '05 #2

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

Similar topics

3
by: LineVoltageHalogen | last post by:
Greeting All, I have a stored proc that dynamically truncates all the tables in my databases. I use a cursor and some dynamic sql for this: ...... create cursor Loop through sysobjects and...
8
by: Nick M | last post by:
Hello All, Excellent info here Thanks! I am very new to using access in general and I am on a learning curve. I'm trying to import an excel workbook (with worksheets) into an access db via a...
6
by: Willie wjb | last post by:
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...
3
by: Reney | last post by:
I am using Access Database in my program. The column in the table that I am going to use has date/time value with Medium Time selected. (HH:mm). The program is recording a clock in time to this...
0
by: J. Giudice | last post by:
I have a database (Jet or Access) that has a Date field in it, WhenModified. This is mapped to a DataTable in ADO.NET using the data wizzard for command statements. When I store a DateTime value...
14
by: Cesar Ronchese | last post by:
Hello! I've built a program that show some dates to users. I got a problem when users have different configured time zone machines, where: - One machine that determined time zone the date...
3
by: bbawa1 | last post by:
Hi, I have a table which has a field ItemsReceived of type datetime. I have a grid view which has two columns. In first column i have to show the data from field ItemsReceived and in second...
3
lagomorphmom
by: lagomorphmom | last post by:
Hi, Can't seem to find a work around for what I thought would be something easy to do. I have a table that contains 3 columns of date values. The date values most often, but not 100%, include the...
8
by: orajit | last post by:
Hello, I have one concern , I have one table that contains huge data. I have created one procedure inside that procedure I am truncating that table . It takes very long time to execute that....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.