473,796 Members | 2,801 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Da taItem("LastUpd ated")%>

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 1640
Hi Wayne,

You can use following code to format Date:

<%# DataBinder.Eval (Container.Data Item, "LastUpdate d", "{0: MM/dd/yyyy}") %>

HTH

Elton Wang
El********@hotm ail.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.Da taItem("LastUpd ated")%>

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****@discuss ions.microsoft. com> wrote in message
news:D1******** *************** ***********@mic rosoft.com...
Hi Wayne,

You can use following code to format Date:

<%# DataBinder.Eval (Container.Data Item, "LastUpdate d", "{0: MM/dd/yyyy}")
%>

HTH

Elton Wang
El********@hotm ail.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.Da taItem("LastUpd ated")%>

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****@discuss ions.microsoft. com> wrote in message
news:D1******** *************** ***********@mic rosoft.com...
Hi Wayne,

You can use following code to format Date:

<%# DataBinder.Eval (Container.Data Item, "LastUpdate d", "{0: MM/dd/yyyy}")
%>

HTH

Elton Wang
El********@hotm ail.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.Da taItem("LastUpd ated")%>

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****@discuss ions.microsoft. com> wrote in message
news:86******** *************** ***********@mic rosoft.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****@discuss ions.microsoft. com> wrote in message
news:D1******** *************** ***********@mic rosoft.com...
> Hi Wayne,
>
> You can use following code to format Date:
>
> <%# DataBinder.Eval (Container.Data Item, "LastUpdate d", "{0:
> MM/dd/yyyy}")
> %>
>
> HTH
>
> Elton Wang
> El********@hotm ail.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.Da taItem("LastUpd ated")%>
>>
>> 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
60935
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 automatically displayed in format, "mm/dd/yyyy" on the ASP page, but it is accepted only in another format, "dd/mon/yy". I want to make it consistent. How can I force it to accept the date in format "mm/dd/yyyy"? The second option would be to force it to...
15
43019
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 mediate between webapps and arbitrary database backends using JDBC. I am very unwilling indeed to write special-case code for particular databases. Our code has worked satisfactorily with many databases, including many instances MS SQLServer 2000...
2
5065
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 date object with the date string which the user inputs from a pop up calendar. somewhat like this..........
10
1897
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 help is appreciated in advance. While running the asp page, I still get an error as Error Type: Microsoft VBScript runtime (0x800A000D) Type mismatch: 'Format' DYNAMIC SQL STATEMENT:
5
816
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
3302
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 to configure server, sql server or program so it always deals with date as mm/dd/yyyy format. Thanks in advance. Roy
20
35638
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 project the date format in vb.code ( not in Windows) and how can I find out which date format the PC Windows is using. Thanks for any response
7
6821
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 text box was 24/06/2006. The other solution I have tried is given by the following two lines that do not compile because a value of date type cannot be converted to datetime:
16
11916
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 report of transactions between a Start & End date. The Tables and forms i believe are UK format "dd/mm/yyyy", However, when I click on "Review Reports" and enter the date as UK "dd/mm/yyyy", it returns nothing.
10
5824
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 date format in the table design, such as: mm/dd/yyyy? What I've done for years is to store the date format in date fields, then on the forms, based on their region, I would set the date formats on form_load
0
9673
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9524
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10217
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10168
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9047
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5440
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5568
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4114
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.