1 to 01 how to get

  • Thread starter Thread starter hoz
  • Start date Start date
H

hoz

set @min = right('0' + cast ( datepart(minute, getdate() ) as char(2)),2)
select @min

I want to get the minutes as 2 char , lets say time is 16:12 , the minute
is 12 . if time is 16:01 , when i get minute 1 , how can i get minute as 2
chars
 
U¿ytkownik "hoz said:
set @min = right('0' + cast ( datepart(minute, getdate() ) as char(2)),2)
select @min

I want to get the minutes as 2 char , lets say time is 16:12 , the minute
is 12 . if time is 16:01 , when i get minute 1 , how can i get minute as 2
chars

Try:
set @min = right('0' + cast ( datepart(minute, getdate() ) as varchar(2)),2)

Grzegorz
 
Your code looks correct. I can't really test for about 1/2 hour though :-)

What's it not doing correctly? Perhaps LTrim your Cast?

Jeff
 
If it's a Windows DataGrid, instantiate a DataGridTableStyle and add a member
to GridColumnStyles for each column that should appear in the grid. Add the
DataGridTableStyle to the TableStyles collection of the DataGrid. Details
are in MSDN.

If it's a Web Form DataGrid, I think you're supposed to be able to do this
with the "Edit Template" wizard - but I've had better luck just coding width
values into the HeaderStyle tags, after I use the wizard to create some bound
columns. Something like this:

<asp:BoundColumn DataField="STATUSASOFDATE" HeaderText="As Of"
DataFormatString="{0:d}"><HeaderStyle Width="144px"></HeaderStyle>

Hope that helps
 
On Thu, 4 Nov 2004 14:22:05 -0800, "Rich"

Or if it's anything else, use:

string.Format("{0:HH:mm}", myTimeValue)
If it's a Windows DataGrid, instantiate a DataGridTableStyle and add a member
to GridColumnStyles for each column that should appear in the grid. Add the
DataGridTableStyle to the TableStyles collection of the DataGrid. Details
are in MSDN.

If it's a Web Form DataGrid, I think you're supposed to be able to do this
with the "Edit Template" wizard - but I've had better luck just coding width
values into the HeaderStyle tags, after I use the wizard to create some bound
columns. Something like this:

<asp:BoundColumn DataField="STATUSASOFDATE" HeaderText="As Of"
DataFormatString="{0:d}"><HeaderStyle Width="144px"></HeaderStyle>

Hope that helps

Otis Mukinfus
http://www.otismukinfus.com
 
Back
Top