[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

asp.net formatting military time

Posted on 2004-08-23
12
Medium Priority
?
671 Views
Last Modified: 2012-06-21
I want to show short date 9/15/04 and military time 23:10

What would I do to convert this my TextTimeIn.Value to that format?

If Not row.IsTimeInNull Then Me.TextTimeIn.Value = row.TimeIn

Its' currently showing this: 8/21/2004 2:38:09 PM

0
Comment
Question by:jamesh1031
  • 5
  • 3
  • 2
  • +1
12 Comments
 

Author Comment

by:jamesh1031
ID: 11873362
This data is stored in one field (date and time) (MS Sql)
0
 
LVL 2

Assisted Solution

by:netjkus
netjkus earned 400 total points
ID: 11873425
string dtformat = "MM/dd/YYYY HH:mm:ss";

string Timenow = DateTime.Now.ToString(dtformat);

Note the Capital HH - makes it 24 hour format.

any question email me.
0
 
LVL 2

Expert Comment

by:netjkus
ID: 11873441
Or if you need to convert a datetime existing, eg.

 Datetime Dttest = GetdatetimefromDBfield();

dttest.ToString(dtformat);
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:jamesh1031
ID: 11873466
So, how do add it to the page?

If Not row.IsTimeInNull Then Me.TextTimeIn.Value = row.TimeIn
0
 
LVL 18

Expert Comment

by:DotNetLover_Baan
ID: 11873594
Hi there,
use...
     If Not row.IsTimeInNull Then Me.TextTimeIn.Value = Format(CType(row.TimeIn , Date), "HH:mm")

-Baan
0
 
LVL 3

Expert Comment

by:gspronych
ID: 11887671
Hi

I found the easiest way to change date formats by changing the page culture.

Click the page, and scroll down to culture in the properties window.
Change the culture to this property for your formatting: en-GB English (United Kingdom)
This culture will shows dates in this format '24/08/2004 16:09:42'
Changing the culture will display times as described by each culture.

Localization can be done project wide, or page specific as I described above.
0
 

Author Comment

by:jamesh1031
ID: 11887902
I couldn't get dotnetlover's method to work....i don't have anywhere where I see "culture" in visual studio.net in a properties window..i may post the question at sql as I want to make sure that the display format won't mess up the db data when saving.
0
 
LVL 3

Accepted Solution

by:
gspronych earned 1200 total points
ID: 11888110
To manually add a culture to a page, add the culture keyword to your page directive.
Click the html tab to view the html version of your page.

Then add this value at the top of the page
culture="en-GB"

My page directive looks like this

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="RTF.aspx.vb" Inherits="Secure.RTF" culture="en-GB"%>

It's worth a try


0
 
LVL 18

Expert Comment

by:DotNetLover_Baan
ID: 11888277
>> "I couldn't get dotnetlover's method to work"<<  
what is the error you are geting ?
0
 

Author Comment

by:jamesh1031
ID: 11888808
no error, just didn't format the date and time.

0
 
LVL 18

Assisted Solution

by:DotNetLover_Baan
DotNetLover_Baan earned 400 total points
ID: 11889042
Hi there...
if you want to change your culture from code....

Imports System.Globalization
Imports System.Threading

Thread.CurrentThread.CurrentCulture = New CultureInfo("en-US")

Then use my earlier post...
visit this link...  http://www.microsoft.com/globaldev/getWR/steps/wrg_date.mspx
-Baan
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses
Course of the Month17 days, 16 hours left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question