Remove the time part from a date

Hello,

I have a datatable with a column of dates and times -  xx/xx/xxxx 12:00:00 AM

I want to remove the12:00:00 AM

Below is two For next loops I tryed with no luck.  I even tryed to cast the listitem.text to a date and it still didn't  work.

Thanks

Steve

Dim

i As Integer = 0

For i = 0 To ds.Tables(0).Rows.Count - 1

Dim li As ListItem = ds.Tables(0).Rows(i).Item(0)

Format(li.Text,

"MM/dd/yyyy")

Next

 

Dim i As Integer = 0

For i = 0 To ds.Tables(0).Rows.Count - 1

Dim li As ListItem = ds.Tables(0).Rows(i).Item(0)

Microsoft.VisualBasic.Left(li.Text,

10)

Next
0
Steve
3/18/2007 4:15:43 AM
asp.net.getting-started 91979 articles. 3 followers. Follow

4 Replies
562 Views

Similar Articles

[PageSpeed] 11

just modify your query as follows

SELECT Name, Id,  CONVERT(varchar,DateColumn,101)  FROM Table1

call the CONVERT function on the DateColumn with format no:101 which is mm/dd/yy


Let the game begin!!

Barcode image generation made easy.
Writing an ActiveX Control in C#
Generating Relational Data From XML Datatype -Part 1
Generating Relational Data From XML Datatype -Part 2
Dynamic XML From SQL Server
0
imran
3/18/2007 10:40:39 AM

Hello Imran.nathani 

I like your idea doing it in the SELECT statement.  Below is the error message and my SELECT statment. I'm not sure what the Name, Id in your select statement is.  F1 is the first column in my table with the date that I want to format.  Thanks for your help!

CommandText = "SELECT F1,F2 CONVERT(varchar,F1,101) FROM C05K.ASC"


Syntax error (missing operator) in query expression 'F2 CONVERT(varchar,F1,101)'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: Syntax error (missing operator) in query expression 'F2 CONVERT(varchar,F1,101)'.

Source Error:

Line 29: 
Line 30:         conn.Open()
Line 31:         da.Fill(ds)
Line 32:         conn.Close()
Line 33: 

0
Steve
3/18/2007 3:39:46 PM

You missed comma between F2 and CONVERT:

SELECT F1,F2, CONVERT(varchar,F1,101) FROM C05K.ASC

0
kipo
3/18/2007 4:12:52 PM
You could also write something like: yourDateVariable.ToShortDateString

Developer in ASP.NET 2.0 and Visual Basic 2005
0
lejdborg
3/18/2007 7:17:33 PM
Reply:

Similar Artilces:

remove time part from a date/time field value
How does one remove or avoid the time part from a date/time field value. For example store 12/12/2006 instead of 12/12/2006 12:00:00 Am --------------------------------------------------No Project Too Eazy.-------------------------------------------------- You can use one of the appropriate Standard DateTime Format Strings such as d or D.Darrell Norton, MVPDarrell Norton's BlogPlease mark this post as answered if it helped you! You should be able to use DateTime dt = DateTime.Now dt.ToString("d")  //this will format as short date time FYI: If you want to do it at the query ...

How to remove the date part of a Date/Time value in MS Access
I am inserting a time value into a MS Access Date/Time field and notice that MS Access does not display the date portion of the value but when I look at the same data in my programming using a TADOTable component I am seeing the date of 12/30/1899 in conjunction with my time value. I read that Access is handling this within MS Access so that when a 0.sometime value is inserted it does not display the date. How do I handle this within my Delphi program so that I can display the time only in a Date/Time type field? Jeff Howard wrote: > I am inserting a time value into a MS Access Date/T...

Removing Time from date time
We would like to form a recordset that would have the datetime column be just the date. We have students visiting our web several times a day and each of these are counted as distinct dates. We would like just the total number of days that they used the web not the total number of times they accessed the web. Thanks Jim You can use date function on datetime column, or use cast. eg: select datetime_col, date(datetime_col), cast(datetime_col as date) from some_table Hope this helps, Goran jmwarren wrote in message <39A66A36.8B355AA6@pilot.msu.edu>... >We would like to form a recordset that would have the datetime column be >just the date. We have students visiting our web several times a day and >each of these are counted as distinct dates. We would like just the >total number of days that they used the web not the total number of >times they accessed the web. > >Thanks >Jim > ASA has a built in function DATE that removes time. Though it's not mentioned in the documentation it works on timestamps too, and since datetime is implemented as timestamp it should solve your problem Anders jmwarren wrote: > We would like to form a recordset that would have the datetime column be > just the date. We have students visiting our web several times a day and > each of these are counted as distinct dates. We would like just the > total number of days that they used the web not the total numbe...

date/time or date and time
I am setting up an SQL database and I will need to get differences in dates. For example I have a start date, start time, completion date and completion time and I want to get the difference between the start and completion. Would it be better to have one field with both date and time in it, or better to have a date field and a time field? Even though I have already started setting up the tables with seperate fields for date and time I am now leaning toward one field with date/time in it. (Only because that is the way I had to do it when setting up an Excel spreadsheet for a similar ta...

Date / Time Field
PB 7.0.3 I have an application that records patient encounters, treatments and referrals for an Emergency Department within a hospital. Each encounter records time to nurse and time to physician - these fields are of datetime format. This application is for statistical purposes only and therefore is not real time (unit clerks key in the necessary data throughout the day). Here is a senerio... Patient A enters the ED and the date / time of encounter is recorded. The date and time that the triage nurse first assesses the patient is recorded (time to nurse) The date and time that th...

Formatting date SQL date to remove time
Hi,I need a way of changing the following SQL statement so that the dates are without the hh:mm:ss tt:"Select DISTINCT([StartDate]) From [Events]"How can this be done?Thanks,Curt. Regards, Curt SELECT CONVERT (VARCHAR, [StartDate], 101) FROM ... For other date formatting types, see http://msdn2.microsoft.com/en-us/library/ms187928.aspxMark replies as answers if they helped you solve the problem. use the following Conversions Convert("urdatecolumn",Varchar,101); and there are more codes for the dateconversions.Its general Syntax is Convert("urdatecolumn",...

How to get powerbuilder library version, date-time stamp at run-time?
Hi, We would like to see list of all libraries of running application along with their version and date/time stamp (in about window). We would like to get version number of compiled powerbuilder libraries (pbd's) at run-time. I don't know if pibbles compiled in dll format have advanced features (as regular dll - where right clicking on it and selecting properties will allow user to see version number of dll). Anyway, compilation of pibbles in dll format is not an option for us. I would like to see if anybody came across a solution and would like to share it with me. I ...

GridView
Hello,I have a column on a GridView that is formatted to only display the time part of a date time field. However, whenever I edit the cell value the Date part of the field is changed to today's date. The way I've got round this is to implement the CellValueChanged event. Is there a better way of doing this? Code is below. private void dgTimeSlots_CellValueChanged(object sender, DataGridViewCellEventArgs e) { int col = e.ColumnIndex; int row = e.RowIndex; if (col >= 0 && row >= 0) { // the correct date ...

Getting Start With .net
hi i'm intersted to learn asp.net (vb or delphi) . i programming with delphi6 but i'd like to tp know something about programming in internet specially with .net . i hear about microsoft.net with delphi 7 that i can programming with delphi in .net .... is it right ? what 's our opinian about it ? and better to learn Vb.Net or continu with delphi(or delphi.net) thanks. Ali Darabian I think there is some support for Delphi in .Net. However, you will find much more support from the user community if you choose a more popular language such as VB.Net or C#. Since your al...

how to get start with .NET
the net help people installed  to my desktop 1-microsoft visual studio .NET enterprise developer 2003 2-microsoft .NET framework 1.1 what else do i need ...???  and how can i try with some simple code in VS.Net and run it to see wat happen...????? please help If you want to develope web applications, then you'll also need IIS on your PC.  That'll require XP-Professional or Windows 2000/2003, but XP-Home edition won't allow IIS installation. As for how to get started, you can search the web for some tutorials or buy a good book on VS.  The topic is way too vast to...

HOW TO COMBINE A DATE COLUMN AND A HOURS COLUMN IN A DATAGRID TO GET FULL DATE AND TIME
Hello There!,          First of all i have a date column and a text box column in my datagrid . i am populating the date column through the below code  DataTable Table3 = new DataTable();         DataColumn Date = new DataColumn();        Date.ColumnName = "Date";   Table3.Columns.Add(Date);  DateTime Crnt_Time =DateTime.Now;        int day = Crnt_Time.Day;        int mnth = Crnt_Time....

How to get week start date, End date for a given week nunber,year?
I want  a javascript function to to get the starting date and end date of a week when I have given the week number (1 to 5), Month number (1 to 12), valid year as parameter. How to do that?Manivannan  You can visited http://www.datejs.com/2007/11/I dont have example.Hope it's help you. try this example function GetWeekStartEndDate(){    var week = 5;    var month = 4;    var year = 2008;        var PositiveOneDay = new Date(new Date('1/2/2000') - new Date('1/1/2000'));   &...

how do i get date time?
i need to collect date time of server. how do i get that date and time. datetime.now gives date and time of local machine of user browsing our website? and it might be different since user can be from any location. server date time will remain unique and there fore i need to collect server date time so kindly tell me how do i collect server date time.   Depends on where the code is run.  If run at server, it shows server time.  If run at client, it shows client time.  Code is the same either way. JeffPlease: Don't forget to click "Mark as Answer" o...

Start Date/Time
Name: Bob Porter Email: rodapoatsuddenlinkdotnet Product: Sunbird Summary: Start Date/Time Comments: I would like to have appointments to be in ascending date/time sequence on the reminder panel Browser Details: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; GTB6; .NET CLR 2.0.50727) From URL: http://hendrix.mozilla.org/ Note to readers: Hendrix gives no expectation of a response to this feedback but if you wish to provide one you must BCC (not CC) the sender for them to see it. ...

How to get date and time
Hi Every One I want present date and time with sends right now i am writing "DateTime.Now.ToString(); " it displays like "2008-12-26 22:35:00" but i want with seconds also like 2008-12-26 22:35:20   please help mePramoda Chakravarthy Vungarala Try this.. DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); Check this link for more DateTime formats.. http://www.mikesdotnetting.com/Article.aspx?ArticleID=23My Blog"Don't be afraid to be wrong; otherwise you'll never be right."...

get date and time
hello i have 2 textbox on my page i want to get date and time in textbox3.text as soon as user enter the partnumber in textbox1.text thanks.   Client or server?  If client-side, are you limited to IE (that is, can you use VBScript)?Peter BrunoneMS MVP, ASP.NETFounder, EasyListBox.comDo the impossible, and go home early....

java date time and utc date time
hi i have a client written in delphi the backend is written in java (webservice) when fetching a date field from the db, through java to delphi (TXSDateTime class), for some reason the date changes. in the db: 30/07/2009 00:00:00 in delphi: xsdatetime.asdatetime = 29/07/2009 23:00:00 (1 hour before) in delphi xsdatetime.asutcdatetime = 29/07/2009 21:00:00 (3 hours before) i guess it's a matter of timezones but all we want is simply to fetch the same date as it appears in the DB what are we missing? thanks amos szust wrote: > hi > > i have a client written in d...

I don't want to cut the time part of date time data type
Hello there? My database is MySql, and I save the date in database as data type is the Date such as '2006-03-30'. However, when I load my data into a dataset, my data in the dataset looks like '03/30/2006 12:00:00 AM'.  So, I tried to set the data type in dataset as Date of data type, but .Net doesn't have Date data type.  Also, I found Date Property under Datetime class. So, could you tell me how can I use Date Property to cut the time part in the Dataset? OR any recommendation?? please....   Some ASP.Net controls have properties designed specifically to format the...

Desired Time Start Date Always Shows Today on Busy Search with Auto-date
When an appointment is scheduled using the Auto-Date and a Busy Search is done the Desired Time Start Date displays today's date. If I schedule the appointment not using the auto-date and do a Busy Search the Desired Time Start Date displays the date for the appointment Can anything be done so the Desired Time Start Date shows the appointment date when scheduled usgin the Auto-Date? Jjanz, It appears that in the past few days you have not received a response to your posting. That concerns us, and has triggered this automated reply. Has your problem been resolved? If ...

just Time or date portion of a date/time field
Good Day, From a DateTime data column how do I get just a Time portin or just a date portion of data to be displayed. i.e from 11/6/2003 10:03:20 AM I need to display date and time seperately in my data display page. Thanks Regards, In code you could use Dim dt as System.Date Dim day, month, year as integer day = dt.Day month= dt.Month year = dt.Year This also works with DateTime In SQL you could use DATEPART(<datepart>,<datetime>) where <datepart> is the abbreviations mentioned in post 385301 and <datetime> is a...

Where to start and how did you get started?
Hi, I have had a feeling for a long time to jump into the adds market for some time due to my low income (shooting for the stars) and I don't have anything better to do these days. But I find it really difficult not to give up due to lack of guides (what I can find atleast) and all the hard words which only makes me confused. But I won't give up. Never. Not sure if this is the right place to post this, but I deffinitly would be really greatfull for help getting started. How did you get started? +If there are any teacher that wanna show me the ropes private, I can give payment with ...

Start/end date... but what about time?
DNN has those nifty Start Date / End Date fields for modules and pages. But what about time? I would like to have a special module appear on a fixed date and at a certain time. Is there any way to achieve this? Since the Start Date and End Date fields are Datetime fields in the database, I tried manipulating them directly using a SQL Database manager, but entering a time does not seem to make a difference. At least in several tests I made, DNN displayed the module regardless of which time I entered, i.e. seemed to only take the date portion of the field. And yes, I did check server time zon...

Getting TIME and DATE formatted. How?
Hi there, since there is a long time gone since I've posted my question to this newsgroup, I think it's time to refraise the last one. I have a SQLAnyWhere database with Power++2.0 on WinNT 4.0 (sp 3). I have a table with some TIME and DATE columns. Is there a way to get these columns' values formatted without using a bound control? I need to get european formats and do not want to format this output on myself. On the SQLAnyWhere help guide I can read that I can use the 'SET OPTION' command but this seems to only want to work with bound controls. Any ...

Remove time from Date field
Hi, I have a datagrid that displays results from a stored procedure. It contains a date column that displays the entered date of the record. This is not a time stamp field and the value stored in the database is just the date. When I run the procedure and fill the datagrid, the column values look like this. 2005-04-06 00:00:00 Does anyone know how to prevent that? Any help would be appreciated. Thanks!"Worry not that no one knows of you, seek to be worth knowing" You can use variouos formatting options to present the date in format you want. Can you post your grid declaration...

Web resources about - Remove the time part from a date - asp.net.getting-started

App Launching On Valentine’s Day Allows Users To Remove All Traces Of Exes From Facebook Timelines
Just in time for Valentine’s Day — launching Thursday, in fact — comes mobile application KillSwitch , which allows users who are still Facebook ...

how do you remove "on this day" app? Did not ask for this app. - Facebook-Hilfeforum - Facebook
Unfortunately, you cannot delete or block this app, and there seem to be some folks out there that enjoy this, so Facebook will use that as justification ...

Platform Updates: New User Object fields, Edge.remove Event and More
New User Object fields, Edge.remove event, and more

Facebook Adds Easier Ways for Users to Remove Third Party Apps
... it announced today . The changes probably won’t create massive changes in Platform traffic, but should make it easier for users to fully remove ...

Photo Eraser - Remove Unwanted Objects from Pictures on the App Store on iTunes
Get Photo Eraser - Remove Unwanted Objects from Pictures on the App Store. See screenshots and ratings, and read customer reviews.

Don't call us: Centrelink bosses remove phone numbers and email from directory
Tom was savvy enough to take his complaints straight to Centrelink management.

Don't call us: Centrelink bosses remove phone numbers and email from directory
Tom was savvy enough to take his complaints straight to Centrelink management.

'Bloody stupid' Facebook rules remove video of dancing 5­-year-­old
A dad in Dunedin, New Zealand has been left bewildered after a 53 second video of his dancing daughter was removed from Facebook.

Yahoo!: Starboard Pushes to Remove the Board, Calling Performance ‘Atrocious’
Shares of Yahoo! ( YHOO ) are unchanged in early trading at $34.80, after activist investors Starboard LP , which owns 1.7% of the shares outstanding ...

Peter King Vows To Support Trump Time To Vow To Remove King From Office
Peter King should retire DuWayne Gregory is the presiding officer of the Suffolk County legislature. In 2010, New York redistricting moved Peter ...

Resources last updated: 3/28/2016 2:03:13 PM