473,399 Members | 2,858 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,399 software developers and data experts.

Format Date from DB

I have an aspx page in which I retrieve data from an SQL Server. At one
point I am retrieving a smalldatetime field and I want to display only
"mm/dd/yy" but the default seems to be to add the time. The code to retrieve
that date field is: <%#Container.DataItem("LastUpdated")%>

I tried adding ".ToString("d")" but it doesn't recognize that as a
formatting function.

How can I format that returned value as mm/dd/yyyy?

Wayne
Nov 19 '05 #1
4 1621
Hi Wayne,

You can use following code to format Date:

<%# DataBinder.Eval(Container.DataItem, "LastUpdated", "{0: MM/dd/yyyy}") %>

HTH

Elton Wang
El********@hotmail.com

"Wayne Wengert" wrote:
I have an aspx page in which I retrieve data from an SQL Server. At one
point I am retrieving a smalldatetime field and I want to display only
"mm/dd/yy" but the default seems to be to add the time. The code to retrieve
that date field is: <%#Container.DataItem("LastUpdated")%>

I tried adding ".ToString("d")" but it doesn't recognize that as a
formatting function.

How can I format that returned value as mm/dd/yyyy?

Wayne

Nov 19 '05 #2
Elton;

Thank you very much. Works perfectly. Where is that documented?

Wayne

"Elton W" <El****@discussions.microsoft.com> wrote in message
news:D1**********************************@microsof t.com...
Hi Wayne,

You can use following code to format Date:

<%# DataBinder.Eval(Container.DataItem, "LastUpdated", "{0: MM/dd/yyyy}")
%>

HTH

Elton Wang
El********@hotmail.com

"Wayne Wengert" wrote:
I have an aspx page in which I retrieve data from an SQL Server. At one
point I am retrieving a smalldatetime field and I want to display only
"mm/dd/yy" but the default seems to be to add the time. The code to
retrieve
that date field is: <%#Container.DataItem("LastUpdated")%>

I tried adding ".ToString("d")" but it doesn't recognize that as a
formatting function.

How can I format that returned value as mm/dd/yyyy?

Wayne

Nov 19 '05 #3
http://msdn.microsoft.com/library/de...evaltopic2.asp
"Wayne Wengert" wrote:
Elton;

Thank you very much. Works perfectly. Where is that documented?

Wayne

"Elton W" <El****@discussions.microsoft.com> wrote in message
news:D1**********************************@microsof t.com...
Hi Wayne,

You can use following code to format Date:

<%# DataBinder.Eval(Container.DataItem, "LastUpdated", "{0: MM/dd/yyyy}")
%>

HTH

Elton Wang
El********@hotmail.com

"Wayne Wengert" wrote:
I have an aspx page in which I retrieve data from an SQL Server. At one
point I am retrieving a smalldatetime field and I want to display only
"mm/dd/yy" but the default seems to be to add the time. The code to
retrieve
that date field is: <%#Container.DataItem("LastUpdated")%>

I tried adding ".ToString("d")" but it doesn't recognize that as a
formatting function.

How can I format that returned value as mm/dd/yyyy?

Wayne


Nov 19 '05 #4
Thanks...

Wayne

"Elton W" <El****@discussions.microsoft.com> wrote in message
news:86**********************************@microsof t.com...
http://msdn.microsoft.com/library/de...evaltopic2.asp
"Wayne Wengert" wrote:
Elton;

Thank you very much. Works perfectly. Where is that documented?

Wayne

"Elton W" <El****@discussions.microsoft.com> wrote in message
news:D1**********************************@microsof t.com...
> Hi Wayne,
>
> You can use following code to format Date:
>
> <%# DataBinder.Eval(Container.DataItem, "LastUpdated", "{0:
> MM/dd/yyyy}")
> %>
>
> HTH
>
> Elton Wang
> El********@hotmail.com
>
>
>
> "Wayne Wengert" wrote:
>
>> I have an aspx page in which I retrieve data from an SQL Server. At
>> one
>> point I am retrieving a smalldatetime field and I want to display only
>> "mm/dd/yy" but the default seems to be to add the time. The code to
>> retrieve
>> that date field is: <%#Container.DataItem("LastUpdated")%>
>>
>> I tried adding ".ToString("d")" but it doesn't recognize that as a
>> formatting function.
>>
>> How can I format that returned value as mm/dd/yyyy?
>>
>> Wayne
>>
>>
>>


Nov 19 '05 #5

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

Similar topics

1
by: jt | last post by:
I posted this yesterday, but I am not seeing this out yet: I am having problems with updating a date field in a certain format. The data is stored in an Oracle database. The date is...
15
by: Simon Brooke | last post by:
I'm investigating a bug a customer has reported in our database abstraction layer, and it's making me very unhappy. Brief summary: I have a database abstraction layer which is intended to...
2
by: amith | last post by:
hi I have written javascript for comparing two dates in US format and finding out whether the start date is greater than the end date and vice versa. In this attempt i have instantiated the...
10
by: Jack | last post by:
Hi, I cannot get the date format correctly in dynamic sql statement, after trying various ways of handling it. I need some help with the date format in the following dynamic sql statement. Any...
5
by: Macca | last post by:
Hi, I have a table which has a date/time field. I am storing them as follows :- 01/01/2005 11:25 01/01/2005 19:44 02/01/2005 05:04
13
by: Roy | last post by:
Hi all, I'm creating a project that should always use this date format when displays the dates or create dates. The back end database is a SQL Server and I like to know what is the logical way...
20
by: andreas | last post by:
When I copy a vb.net project using date formats from one PC with a windows date format f.e. dd/mm/yyyy to another PC having a format yy/mm/dd then I get errors. How can I change for a while in the...
7
by: Richiep | last post by:
I am trying to get a UK format date of dd/mm/yyyy. Why does the following subroutine not return a valid date in a web form? The date returned is #12:00:00 AM# but the date I entered into the...
16
by: Mik | last post by:
I apologise if this post seems a little basic, but I am a newbie and have NO access knowledge. I have downloaded the Accounts Ledger from the Microsoft Website. It allows the user to review a...
10
by: ARC | last post by:
Hello all, General question for back-end database that has numerous date fields where the database will be used in regions that put the month first, and regions that do not. Should I save a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
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,...

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.