Getting just the date from a "datetime" sql column along with other data of different formats


I have a web page that gets the current user, then goes into a database and gets a list of invoices, this includes: invoice numbers, the date of the invoice, the date the invoice was paid, and the amount of the invoice.

The data is then bound to a repeater control and displayed.

i need a way to get just the date and not the date and time from the datetime columns.

Here is my code that i have now:

This next part gets the current user, then creates the selection string and binds the repeater to the data.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Dim UserID As String

UserID = Membership.GetUser.ProviderUserKey.ToString

"UserID").DefaultValue = UserID

Repeater1.DataSource = SqlDataSource1


End Sub

 The Select statement and the repeater:

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:User %>"

SelectCommand="SELECT * FROM [Invoices] WHERE ([UserID] = @UserID) ORDER BY [InvoiceID], [Date]">


<asp:Parameter Name="UserID" Type="String" />



<span style="color: #000000"><strong>Your Invoice History:<br />

<br />


<form id="Form1" runat="server">

<asp:Repeater ID="Repeater1" runat="server">


&nbsp;<span style="color: #000000">InvoiceID: </span>

<asp:Label ID="InvoiceIDLabel" runat="server" Text='<%# Bind("InvoiceID") %>' ForeColor="Black"></asp:Label><span

style="color: #000000">,&nbsp; Date: </span>

<asp:Label ID="DateLabel" runat="server" Text='<%# Bind("Date") %>' ForeColor="Black"></asp:Label><span

style="color: #000000">,&nbsp; Paid: </span>

<asp:Label ID="PaidLabel" runat="server" Text='<%# Bind("Paid") %>' ForeColor="Black"></asp:Label><span

style="color: #000000">,&nbsp; Amount: </span>

<asp:Label ID="AmountLabel" runat="server" Text='<%# Bind("Amount") %>' ForeColor="Black"></asp:Label><span

style="color: #000000">,&nbsp; &nbsp;<a href="/invoices/<%#Eval("UserID") %>/<%#Eval("InvoiceID") %>.pdf"><strong>View</strong></a></span><br /><br />



 Thank you in advance for your help.

7/20/2008 9:22:51 PM 29906 articles. 0 followers. Follow

1 Replies

Similar Articles

[PageSpeed] 25

You can specify an optional parameter to Bind which describes the format of the variable.

So instead of just doing Bind("Date") you can do:

Bind("Date", "{0:yyyy/MM/dd}")

Good luck!

If this post was useful to you, please mark it as answer. Thank you!
7/20/2008 10:14:51 PM

Similar Artilces:

What´s the purpose of "classifieds-categories.sql" "classifieds-add.sql""classifieds-remove.sql"?
 Hello all, what´s the purpose of the scripts I enunciated above on the classified starter kit?  "classifieds-categories.sql"  seems to create the initial parent categories, the others 2 names sugest they are used to add and remove ads, but i cant get how.There are 10 types of people in this world:Those who understand binary and those who don't. The classifieds starter kit is ready for upload right out of the box. Any .sql files you find in App_Data are scripts of the database.They are there to make it easy for uploading your site. So if you were not mak...

SQL: Column names, can ONLY get "name" instead of ""
Hey all, When iterating through column names returned from a query, I need to get "" rather than just "name" Check it out: If I have an SQL statement "SELECT table1.ID, table2.ID FROM table1, table2;" And table1 has a column name 'ID' and table2 has a column name 'ID' aswell, and i run the query, the dataset will contain column names 'ID' and 'ID' instead of 'table1.ID' and 'table2.ID' It is extremely important that I can differenciate between the 2 fields, and know where each of them come from. The same thing happen...

C# DateTime and SQL Server "DateTime" column type
If I have a property in a class that will be set to a date returned from a SQL Server DateTime column... Should my property be of type "string" or type "DateTime". Hi Son Volt,You would have to use DateTime type in your class.Good Coding!Javier Luna Villa El Salvador for world!...

Datawindow "Design Data Source" and "SQL" not available
Just migrated from PB 6.5 to PB 8.0.1 The Data Source for my datawindow is a stored proc, however, the item "Data Source" under the Design menu item is not availabe( grayed out) for selection as well as the "SQL" from the Painterbar. How do I get to view the stored proc selection? mdavis This has been moved to a not so obvious place. In the column specifications tab, right click and select Stored Procedure... from the popup menu. Good Luck Michael Walker Cascadia Software wrote: > Just migrated from PB 6.5 to PB 8.0.1 >...

sql data type "text" is what in .net?
What is the equivalent data type in .net for the sql data type "text"? I can pull varchars from the db as strings, but not this field with the type text. I get the error System.IndexOutOfRangeException: Description But if I change the type in the db, everything works. But, this field needs to be longer than a varchar. The line the error is on: _Description = Convert.ToString(dr(DESCRIPTION_FIELDNAME)) I tried using other types or not converting, no luck. This article has this to say about getting blobs: "The main difference is that in ADO.NET, you ne...

Getting Month" january" instead of "1" in SQL query
Hi Problem solvers The Usertravelactivity table on which i run this query has Columns like CreatedDate (as Datetime) Here is my Query SELECT SalesUserID,Month(CreatedDate) as Month FROM UsertravelActivity Where Month(CreatedDate) In('10','11','12') And Year(CreatedDate)=@Year1 and SalesUserId =@SalesUserID union all SELECT SalesUserID,Month(CreatedDate) as Month FROM UsertravelActivity Where Month(CreatedDate) not In('10','11','12') And Year(CreatedDate)=@Year2 and SalesUserId =@SalesUserID END The outPut now i get is: SalesUSerID ...

SQL error: java.sql.SQLException: Column "-n/a-" not found
Good Morning, I am getting the above SQL error when I define a new variable in my select statement. This syntax did not generate an error message in the V9 beta release. Is this select syntax no longer permitted? Or am I missing some other issue? The error message occurs on new variables in the select regardless of the db element being the index. The error message ceases if I remove the "nextid" verbage from the select. Entire text of code and command winow output are below. Thanks much for your input, and thanks (belatedly) for your input on my previous post. Ca...

Date for Sybase SQL Anywhere 5.5 is "not compatible" with the data type date for Oracle 7.3?
Hello! We have a problem with PowerBuilder dates treatment with different Database type. The data type date for Sybase SQL Anywhere 5.5 is "not compatible" with the data type date for Oracle 7.3. We create a DataWindow for Sybase table that include date fields. This DataWindow executed with Oracle return date error (we recuperate ??/??/??). If we create this DataWindow for Oracle, the date fields are automatically assigned such as DateTime and this object not run in Sybase (remember the different data access: GetItemDate and GetItemDateTime). It's possible t...

.ALLCOL("%COLUMN%", " ", ", ", ", ")
Do you know anyway for me to exclude a subset of columns returned by this function. We have two columns (rec_user and rec_datetime) which are in all of our tables, but when generating triggers I want automatically generate a script which does not include those two columns but does include all other columns in that table. Bruce I should add that I am using PD Bruce "Bruce Lamb" <> wrote in message > Do you know anyway for me to exclude a subset of columns returned by this > function. ...

Converting Excel "general" date into DateTime(Sql)
Hi,  I have an odd request.... I am importing data from an excel spreadsheet to a sql db. Inside the excel spreadsheet, I have a column with dates in it, I need these dates to be imported as text to the sql DB field(which is a varchar datatype).   The problem is, at the moment, if I insert a date 2006/08/30 it displays it like this in the sql DB: 38959 Is there a way this can be converted back to the date? even possibly before it is stored in the sql DB ? I am currently bulk copying the excel data to sql DB. The code im using is below: Thank you for any help/assistance Dim e...

How to display the data from" SQL SERVER" Database in "aspx" page by CHART
Hello, nice to have meet so many helpful friends. Would you please do me a favour?There is much difficulty in solving the problem. I am trying to display the data from" SQL SERVER" Database in "aspx" page by CHART,For example: So that,I can see the data fuctioning In <Microsoft.Office.Interop.Owc>,But I failed. Would you please provide me a real case and give me some explanation ? Your kind help would be highly appreciated!I'm flying.... ...

How to give "And" and "OR" in my sql query?
      My layout (.aspx) have 3 TextBox and 2 Dropdownlist and 1 Button which just looks like Search KeyWord 【Texbox1】DorpDownList1 (have 2 items "And" and "Or")  【TextBox2】DorpDownList2 (have 2 items "And" and "Or") 【TextBox3】 Button ( this Button is for submit query)   1 "txtQuery" style="Z-INDEX: 101; LEFT: 152px; POSITION: absolute; TOP: 32px" runat="server" 2 Width="264px"> 3 "ddlBoolean" style="Z-INDEX: 102; LEFT: 152px; ...

regarding "in" and "=" in a SQL query
Hi, I am using a sybase database client . When i use "in" in a complex nested query say "select * from emp where emp_id in (select emp_id ..........)" then the execution time is really slow but in the same nested query when i use = as in "select * from emp where emp_id = (select emp_id ..........)", then the query is fast. Is there any particular reason for the same? Regards, Supreeth The obvious difference is that the "=" implies that the subquery can only return a single value as opposed to the "in" which implies that th...

SQL syntax opertators: "= any" and "= all"
Hi all, Does anyone ever use the operator of ANY and ALL in the data source of the datawindow? If yes, can you tell me what is the benefit and the context of how to use it? Thanks, Kevin Kevin, Guess you're using Oracle...Just saw that in my oracle Book.. For ANY..when testing for equivalence (= ANY (a,b,c..etc)), this is the same as IN For ALL, my docs say tests that relationship specified is true for every element of the list provided... HTH -- Evita R. Chapa Senior Systems Analyst II Command Technologies, Inc. "kdinh" <kdinh@cayenta...

Web resources about - Getting just the date from a "datetime" sql column along with other data of different formats -

Resources last updated: 12/22/2015 7:51:12 PM