How to Stop Displaying 12am Time in VB ASP.NET from Date/Time field in Access DB

I am using VB in ASP.NET to display records from a table in Access.  The goal is to display all records with a datestamp from today.  The problem is a timestamp appears in ASP.NET even though there is no timestamp, just a date, in the Date/Time field in the Access DB.  All records have the time 12:00:00 AM after the date, and I do not want 12:00:00 AM to appear.  How do I get rid of it?


Here is my code:

--------------------------------------------------

 <%@ Page Explicit="True" Language="VB" %>

<html>
<head>

<title>Test Table</title>

<script runat="server">

Sub Page_Load
        
        Dim dbconn, sql, dbcomm, dbread
        dbconn = New Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=" & Server.MapPath("db_SIDteam.mdb"))
        dbconn.Open()
        
        Dim DtToday
        DtToday = "#" & Date.Today & "#"
        Label1.Text = DtToday
        
        sql = "SELECT * FROM tbl_Test WHERE Dt=" & DtToday
        Label2.Text = sql
        dbcomm = New Data.OleDb.OleDbCommand(sql, dbconn)
        dbread = dbcomm.ExecuteReader()
        customers.DataSource = dbread
        customers.DataBind()
        dbread.Close()
        dbconn.Close()

    End Sub
    
</script>
</head>

<body>

<form runat="server">

<h2></h2>
    <asp:Label ID="Label1" runat="server"></asp:Label><br />
    <asp:Label ID="Label2" runat="server"></asp:Label>

<asp:Repeater id="customers" runat="server">

<HeaderTemplate>
<table border="0" width="100%">
</HeaderTemplate>

<ItemTemplate>
<tr>
<td><%#Container.DataItem("ID")%></td>
<td><%#Container.DataItem("Dt")%></td>
</tr>
</ItemTemplate>

<FooterTemplate>
</table>
</FooterTemplate>

</asp:Repeater>

</form>
</body>
</html>

--------------------------------------------------


Here are the results in a browser:

--------------------------------------------------

#3/24/2008#
SELECT * FROM tbl_Test WHERE Dt=#3/24/2008#

1
3/24/2008 12:00:00 AM
2
3/24/2008 12:00:00 AM
3
3/24/2008 12:00:00 AM

 --------------------------------------------------

0
Kitsune
3/24/2008 3:11:03 PM
asp.net.access-datasource 4679 articles. 0 followers. Follow

3 Replies
881 Views

Similar Articles

[PageSpeed] 50

 

Kitsune-chan:
<td><%#Container.DataItem("Dt")%></td>

A better way would be to change it on the presentation side. Try this: 

<td><%#Container.DataItem("Dt").ToShortDateString%></td>
 
Thanks,
Max
Let Me Google That For You!
1
bullpit
3/24/2008 3:44:32 PM

 Try the following: 

<td><%# String.Format("{0:d}", Container.DataItem("Dt"))%></td>
 



Please remember to "mark as answered" posts that have helped you.

-----
http://lsudotnet.blogspot.com
1
LSU
3/24/2008 3:44:48 PM

It worked!  Thanks!!!

 
<td><%#Container.DataItem("Dt").ToShortDateString%></td>

------------------------------------------- 

#3/24/2008#
SELECT * FROM tbl_Test WHERE Dt=#3/24/2008#

1
3/24/2008
2
3/24/2008
3
3/24/2008

 

1
Kitsune
3/24/2008 3:47:15 PM
Reply:

Similar Artilces:

How to display the Current Date and Time in vb.net
Hi, How to display the Current Date and Time in this coding. Format :  Day, DD MONTH YYYY Eg: Tuesday, 02 September 2008   <asp:Label ID="Label2" CssClass="CenterTextLabel" runat="server" width="100%" Font-Bold="True" Font-Size="X-Large" ForeColor="White" Height="30px" BackColor="WhiteSmoke" ></asp:Label><br /> Thanks  Label1.Text = DateTime.Now.ToLongDateString();Chandra mohan.Ihttp://chandu2u.wordpress.com/. Thanks Chandru,      &...

Inserting Date into Access Date/Time Field
Everytime i capture a date from an asp:dropdownlist and try to insert it into an access date/time field i keep getting a Data type mismatch in criteria expression error (0x80040e07). is there a way i need to format the data before inserting? Any help would be ace!1 using System; 2 using System.Data; 3 using System.Data.OleDb; 4 using System.Configuration; 5 using System.Web; 6 using System.Web.Security; 7 using System.Web.UI; 8 using System.Web.UI.WebControls; 9 using System.Web.UI.WebControls.WebParts; 10 using System.Web.UI.HtmlControls; 11 12 ...

Time difference between two time in vb .net
Hi friends, I need to calculate the time difference between two time: eg: 11:56:00PM and 12:12:00 Am ouput is 16 minutes. Can any one give me the code for it. Thanks, venkat..    http://www.google.com/search?source=ig&hl=en&rlz=&q=vb.net+time+difference&aq=0&oq=vb.net+time+   venkatramcse:I need to calculate the time difference between two time: eg: 11:56:00PM and 12:12:00 Am ouput is 16 minutes. Can any one give me the code for it. Here's an example:C#  DateTime dFrom; DateTime dTo; ...

Accessing a password protected Access 2002 DB from .Net
Here is my connection string: Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("trivia.mdb") & ";Database Password=jeuxdemots;" but I get the following error: Not a valid password. 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: Not a valid password. The password is the right one, what am I doing ...

Access Net work mapped drive VB.NET
Hi I have a docuemnt mangemnt system coded in VB.NET. The system sometimes needs to get documents from Network mapped drive and shared drives. In development machine everything works fine. But when I moved the code to Test serever, it could not access the mapped drives. I tried all security settings. But still could not. I tried unc path, but it throws In valid user exception. Can anybody help m eto solve this issue. Thank you Jikk Hi Jikk, What login is your app running under? Whichever it is, it has to have permission to access the network, which ASPNET doesn'...

Fastest SQL access time in .net
need advice on the following I have 2 tables table 1 - remote, cant use an SP table 2 - local, can use a SP I do a select on Table1 and it returns the results, I want to insert all these results into table 2 The problem is that the first table is really slow to access, I have a string of booking Id's i need to pass it and it keeps timing out on a simple select...its the DB! its on rubbish HW and is badly designed but I cant do anything about that so I have to use the most efficent method of getting the data out, or simply copying the required records between the 2 tab...

Time elapsed between two dates in VB.Net?
Can anyone guide me as to how to display on a text box the number of years and months that have past between today and the date from a calendar datepicker placed on a form from which the user will select the account opening date. I want display on the text box "This account is x years and x months old". Thanks so much!  Manuel http://forums.asp.net/p/1289294/2486719.aspxhttp://forums.asp.net/t/697711.aspx Regards,Vinz"Code, Beer and Music" that's my way of being a programmer!How to get your Forum Question Answered | Blog | CodeASP.NET you should be able t...

how can I access MS Access db on the remote website, at design-time?
Hello! I have a remote website, which I open using Visual Studio. And there is located my data.db access file. Is it possible to create Dataset at design time, which will read the data from that db? When I create the dataset, and trying to add database, there is Oledb data provider, but it wants to work only with local files I need to add design-time dataset, to use them in ReportView. Thank you in advanceArtashes...

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 ...

DBI, MS Access, inserting/updating a Access Date/Time value
Hi, Does anyone have any idea what is up with Microsoft Access and its ridiculous Date/Time formatting options? It doesn't seem to matter what format I attempt to insert with. The directory and db file permissions are all Full Control. I'm using the "#" around the Date/Time format as required. The database has nothing as the Format in Design view on the General tab. The insert below has never worked once. On the up side if I run an insert that has no mention of the Date/Time field then it will just insert the record using the =Now() function as the default va...

accessing MS Access from .net
hi I am accessing ms access data base which has a table called customers. when i try to insert data into the table i am gettign the error like "Operation must use an updatable query" and the line its showing is myOleDbcommand.ExecuteNonQuery() here is my code in page lode event Sub Page_Load(Sender As Object, E As EventArgs) Dim StrConnectString as String Dim strStatement as String strConnectSTring = "Provider=Microsoft.Jet.OLEDB.4.0;Password='';User ID=Admin;Data Source=C:\Inetpub\wwwroot\Srinu\WebApplication2\...

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...

Passing integer array from VB.NET to Access VBA Code (Access 2003 Interop)
Hello, I'm working on a small project to take a current Access database and move it online. I'm using Access automation using Interop (even though its not recommended, but the service wont be used very often). I have the majority of the code working great, except on one VBA function where I pass it an array of integers. Below is a blurp of the code: VBA function: --------------------------------------------------------------------------------------------------------- Public Sub OutputScheduler0708(ProgramId() As Integer, ProgramTypeID() As Integer, ProgramCnt() As Integer, XLSOut...

How do you enter Stored Procedures in VB.NET (Using Access DB)??
I'm using Microsoft Access 2003 and I'm using VB.Net. I'm trying to save a Stored Procedure for the application but when I enter the code into the SQL view of MS Access Query area it throws back errors. The Stored Procedure I'm trying to use is as follows:CREATE PROCEDURE dbo.CheckPassword(  @username Varchar(20)  @password Varchar(20))ASIf Exists(  Select User_ID from UserList Where User_Username = @username And User_Password = @password)Return 0 You must run the SQL command over oledb. You dont.  Microsoft Access Does not support Stored Procedures.  Yo...

Sending SMS using vb.net or C#.net using vb.net or c#.net
Hi  My requirement is I hav one csv file with these fields id,mobilenum,messgae,status.intiallu staus is 0. once i read the all fileds and take that mobile number.using tat mobile number  i need to send sms .after sending sms i shuld change status as 1 How to send sms thru coding (please dont provide any links.if it is provide also please give working links becox i checked codeproject .i didnt get any nice link. and also provide the how to update the status field im csv file   Thank ssandhya   To send SMS, you need some third party SMS providers. if you consul...

Web resources about - How to Stop Displaying 12am Time in VB ASP.NET from Date/Time field in Access DB - asp.net.access-datasource

List of mammals displaying homosexual behavior - Wikipedia, the free encyclopedia
For these mammals, there is documented evidence of homosexual behavior of one or more of the following kinds: sexual behavior , courtship , affection ...

Facebook Displaying Page Insights On Page Admins’ Personal Pages?
Some Facebook page administrators are seeing modules on their personal pages displaying page insights ad, campaign , and like totals for pages ...

Facebook Displaying Unread Messages from Pages in a New Updates Module
Facebook is displaying a new “Updates” sidebar module which shows some users unread messages sent to them by Pages. Users will see the Updates ...

Don Lemon Holds Up Sign Displaying the N-Word, Uncensored, on Air CNN Live - YouTube
Don Lemon Holds Up Sign Displaying the N-Word, Uncensored, on Air Lemon held up a Confederate flag first before holding up the sign. He asked, ...

Hazelwood coal mine fire: Morwell residents displaying symptoms similar to cigarette smokers, expert ...
An expert says some locals near Victoria's Hazelwood mine fire have symptoms similar to cigarette smokers.

Police accused of displaying fake G20 weapons
Toronto's top police officer misled the public by displaying fake weapons used in a medieval-themed role-playing game to help justify their actions ...

No charges for U.S. host for displaying high-capacity magazine on TV
NBC television journalist David Gregory won't face charges for displaying a high-capacity ammunition magazine on his "Meet the Press" news program ...

Jays' Escobar suspended three games for displaying slur
Toronto Blue Jays shortstop Yunel Escobar has been suspended three games for displaying a homophobic slur on his eye-black during a game on Saturday. ...

Google Play Store now displaying age-based ratings
We reported back in May that Google was adding age-based ratings to all apps in the Play Store as determined by the International Age Rating ...

Apple displaying Ferraris & other cars at WWDC hinting at CarPlay announcements
... 2014 Filed under: AAPL Company , iOS Continue reading more about AAPL Company and iOS at 9to5Mac . What do you think? Discuss "Apple displaying ...

Resources last updated: 12/12/2015 8:23:21 AM