Solved

asp.net formatting military time

Posted on 2004-08-23
12
640 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
Comment Utility
This data is stored in one field (date and time) (MS Sql)
0
 
LVL 2

Assisted Solution

by:netjkus
netjkus earned 100 total points
Comment Utility
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
Comment Utility
Or if you need to convert a datetime existing, eg.

 Datetime Dttest = GetdatetimefromDBfield();

dttest.ToString(dtformat);
0
 

Author Comment

by:jamesh1031
Comment Utility
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
Comment Utility
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
Comment Utility
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Author Comment

by:jamesh1031
Comment Utility
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 300 total points
Comment Utility
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
Comment Utility
>> "I couldn't get dotnetlover's method to work"<<  
what is the error you are geting ?
0
 

Author Comment

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

0
 
LVL 18

Assisted Solution

by:DotNetLover_Baan
DotNetLover_Baan earned 100 total points
Comment Utility
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
 

Author Comment

by:jamesh1031
Comment Utility
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video discusses moving either the default database or any database to a new volume.

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now