Showing posts with label entering. Show all posts
Showing posts with label entering. Show all posts

Wednesday, March 7, 2012

Format of date parameters

It seems quite easy to format date parameters any way we like when displaying
a report, but how do we set the date format to use when entering that date -
as an input parameter. Everything works fine with if we accept the default
US style (MM/dd/yyyy) but we need to use dd/MM/yyyy.
Can we force the system to use this format or do we have to manipulate a
string parameter and live with it?It would be nice if there were a calendar drop down when a datetime parameter
is specified.
"Stuart" wrote:
> It seems quite easy to format date parameters any way we like when displaying
> a report, but how do we set the date format to use when entering that date -
> as an input parameter. Everything works fine with if we accept the default
> US style (MM/dd/yyyy) but we need to use dd/MM/yyyy.
> Can we force the system to use this format or do we have to manipulate a
> string parameter and live with it?
>

Sunday, February 19, 2012

format column data

Hi,

I am entering values from .Net app to a table in Sql 2k. The Identity field needs to be in 'ABC0000012' format (3 fixed letters and 7 digits - incremented by 1). My code MUST BE within a stored_proc. I am trying to format the column to have reqd. number of preceeding zeros. How can I get those ?

Pls help.
Sam

I am not sure exactly what you mean but I am going to take a guess.... Does this help?

Foo = "ABC" & SubStr(CStr(10000000 + id),2,7)

|||

Sara.. Thanks for guess.. here is what I am trying:

I have a constant prefix to which I need to apend value in the Identity column (should be 7 digits) -- so the total alpha numeric number will be 10 places:

examples:
say ID column value is 2 my final output should look like ABC0000002
say ID column value is 123 my final output should look like ABC0000123
say ID column value is 123456 my final output should look like ABC0123456

question is how to pad ID column value with preceeding zeroes?

Thanks, Sam

|||SELECT
'ABC' + right('0000000'+ convert(varchar,[id]), 7)
, othercolumns
FROM
yourTable