Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Time Issue

Status
Not open for further replies.

TechUser23

IS-IT--Management
Mar 8, 2007
28
US
I know this is an odd request but ... In T-SQL, I have 4 fields causing me Time nightmares ...

Code:
StrtHour=convert(varchar(2),datepart(hour,Start)), 
StrtMin=convert(varchar(2),datepart(minute,Start)), 
StpHour=convert(varchar(2),datepart(hour,Stop)), 
StpMin=convert(varchar(2),datepart(minute,Stop)),

If the time is 8:00 AM, I am getting 8 for the hour and just one 0 on the minute. Since I'm having issues in SQL, I was looking to program Crystal to do some fancy handling ... Is it possible to code the minute field to report the second "0"? So basically, its happening on the top of the hour ... 7:00 am reads 7:0 ...

Is it possible to do code crystal to add in my second 0 ... anyone that can help me will be my hero. LOL Thanks in advance
 
You can show leading zeros for a two-digit number using
Code:
ToText({your.value}, "00")
You might also use the "Time" command to put together hours, minutes and even seconds as something Crystal will recognise as a time.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Try this Formula:Time2
if tonumber({Table.Field})<100000
then "0"+ totext(tonumber({Table.Field}))else if
tonumber({Table.Field})<10000
then "00"+ totext(tonumber({Table.Field}))else if
tonumber({Table.Field})<1000
then "000"+ totext(tonumber({Table.Field}))else if
tonumber({Table.Field})<100
then "0000"+ totext(tonumber({Table.Field}))
else totext({Table.Field})

Next formual:Time
if tonumber({Table.Field})>0 then left ({@TIME2},2)+ ":"+ mid ({@TIME2},3,1)+mid ({@TIME2},5,1)+ ":" + mid({@TIME2},6,2)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top