| | |
How to split datetime format?
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
You have a datetime. How you display it is up to you. The DateTime object supports multiple methods for displaying the date, as well as an overridden ToString that can take a format.
http://msdn2.microsoft.com/en-us/lib...e_methods.aspx
If for some reason you want it returned from the database as a string that is already formatted, the question is more relevant in an SQL forum, since it then becomes database dependent. SQL Server supports the convert function for dates, i.e.
convert(varchar,mydatefield,101)
http://msdn2.microsoft.com/en-us/lib...e_methods.aspx
If for some reason you want it returned from the database as a string that is already formatted, the question is more relevant in an SQL forum, since it then becomes database dependent. SQL Server supports the convert function for dates, i.e.
convert(varchar,mydatefield,101)
Last edited by nikkiH; Dec 29th, 2006 at 9:56 am.
Google is your friend. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
Bored? Visit http://www.kaelisspace.com/
Bored? Visit http://www.kaelisspace.com/
Good points nikkiH!
One thing that can be done as well is to retrieve the date/time from the database as stored and use the parse/format methods in ASP.NET to produce the desired output.
Satees - the links nikkiH provide is an excellent starting point.
One thing that can be done as well is to retrieve the date/time from the database as stored and use the parse/format methods in ASP.NET to produce the desired output.
Satees - the links nikkiH provide is an excellent starting point.
Last edited by Paladine; Dec 30th, 2006 at 3:27 pm.
•
•
Join Date: Jun 2006
Posts: 3
Reputation:
Solved Threads: 0
If its in a gridview, something like this works
The whole grdiview might look something like this
ASP.NET Syntax (Toggle Plain Text)
<%# String.Format("{0:d}",Eval("dtmExpiration")) %>
ASP.NET Syntax (Toggle Plain Text)
<asp:GridView Width="100%" BorderWidth="0" CellPadding="0" CellSpacing="0" BorderColor="white" AutoGenerateColumns="FALSE" ShowHeader="false" ID="gvStores" runat="server"> <Columns> <asp:TemplateField> <ItemTemplate> <table> <tr> <td valign="top" width="110px"> <img border="0" src="images/<%# Eval("strLogo")%>" /> </td> <td valign="top" class="bluebodytext"> <%# Eval("txtDescription")%> <i>Offer Expires <%# String.Format("{0:d}",Eval("dtmExpiration")) %> </i> </td> </tr> </table> <div class="row"> </div> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView>
Last edited by Paladine; Jan 4th, 2007 at 8:17 pm. Reason: Adding Code Blocks
•
•
Join Date: Nov 2007
Posts: 1
Reputation:
Solved Threads: 0
you should check this out: http://developerstips.wordpress.com/...umn-in-aspnet/
![]() |
Similar Threads
- Want Date Format in dd/mm/yyyy in ASP.Net With C#. (C#)
- datetime format in ms sql (MS SQL)
- datetime format (MS SQL)
- need urgent help for a query (MS SQL)
- Log file rotation script (Perl)
Other Threads in the ASP.NET Forum
- Previous Thread: background-color:"9E0039" works in IE but not mozilla, solution?
- Next Thread: Content Changes across pages via Drop-Down Box
| Thread Tools | Search this Thread |
.net 2.0 3.5 activexcontrol advice ajax appliances asp asp.net bc30451 beginner bottomasp.net browser businesslogiclayer button c# c#gridviewcolumn cac checkbox class click commonfunctions compatible confirmationcodegeneration content contenttype control countryselector courier css database datagrid datagridview datagridviewcheckbox datalist deadlock deployment development dgv dialog dropdownmenu dynamic edit embeddingactivexcontrol expose findcontrol flash flv formatdecimal forms formview gridview homeedition iframe iis javascript jquery list menu mono mssql multistepregistration nameisnotdeclared novell objects order problem ratings rotatepage save search security serializesmo.table sessionvariables silverlight smartcard sql sqlserver2005 ssl suse textbox tracking treeview unauthorized validatedate validation vb.net video virtualdirectory vista visual-studio visualstudio vs2008 web webarchitecture webdevelopemnt webdevelopment wizard xml youareanotmemberofthedebuggerusers






