Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Format Time

Author  Topic 

olily
Starting Member

37 Posts

Posted - 2002-07-24 : 01:26:16
I wrote a few sql statements to format the time to military format but the statements are too long and redundant. Is there any simpler way to do this task? Datatype is varchar(10) and sample data:
430pm
5:15pm
8:45am
6:00am
500am
09:10am
0430am
0300pm
1230pm
100AM
1200AM
145PM
9:10PM
08:00PM

joldham
Wiseass Yak Posting Master

300 Posts

Posted - 2002-07-24 : 07:51:37
If you run the following Update statement, it will make the information in the table easier to parse through.

Update Military_Date
Set Brief_Date = replace(Brief_Date, ':', '')
Where charindex(':', Brief_Date) > 0

Update Military_Date
Set Brief_Date = '0' + Brief_Date
Where Len(Brief_Date) = 5

If you can, I would put constraints on your table to make sure that the information being put into this column is in the correct format (i.e. no ':', datatype of char(6), etc.)

Jeremy



Edited by - joldham on 07/24/2002 08:08:02

Edited by - joldham on 07/24/2002 08:08:36
Go to Top of Page
   

- Advertisement -