Showing posts with label syntax. Show all posts
Showing posts with label syntax. Show all posts

Thursday, March 29, 2012

Formula Syntax

Is there a sood reference for the syntax that is used in formulas?
Here's the thing...
If .NET there is no IIF Function...so I think, its SQL Syntax.
Then there's the Bang notation (!) so I think its Access's syntax
But I can say:
=IIF(Fields!LAST_NAME.Value.indexOf("A") = 0, "Starts With 'A'", "Does not
start with 'A'")
...which is leveraging String.indexOf which is part of the .NET Model (C#?).
...but its not case sensitive (VB.NET?)
so if anyone out there had a really strong understanding of what I can do
syntactically, or exactly WHAT is parsing these expressions, I'd appreciate
it. It would help us all know what we can and can not do.Thank you for the comments. My observations are very similar to yours. I
believe the expression handler parallels the functions found here, which
you will notice are VB.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/
vaoriVBRuntimeLibraryKeywords.asp
| Thread-Topic: Formula Syntax
| thread-index: AcTFoYa5vwda7O/DQ22hld4dBt+/1w==| X-WBNR-Posting-Host: 216.88.246.15
| From: =?Utf-8?B?RGF2aWQgSmVzc2Vl?= <DavidJessee@.discussions.microsoft.com>
| Subject: Formula Syntax
| Date: Mon, 8 Nov 2004 06:45:01 -0800
| Lines: 15
| Message-ID: <E890CF96-C782-440B-A69B-14597AD8E89D@.microsoft.com>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.sqlserver.reportingsvcs
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
| Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: cpmsftngxa10.phx.gbl microsoft.public.sqlserver.reportingsvcs:34345
| X-Tomcat-NG: microsoft.public.sqlserver.reportingsvcs
|
| Is there a sood reference for the syntax that is used in formulas?
| Here's the thing...
|
| If .NET there is no IIF Function...so I think, its SQL Syntax.
| Then there's the Bang notation (!) so I think its Access's syntax
| But I can say:
| =IIF(Fields!LAST_NAME.Value.indexOf("A") = 0, "Starts With 'A'", "Does
not
| start with 'A'")
| ...which is leveraging String.indexOf which is part of the .NET Model
(C#?).
| ...but its not case sensitive (VB.NET?)
|
| so if anyone out there had a really strong understanding of what I can do
| syntactically, or exactly WHAT is parsing these expressions, I'd
appreciate
| it. It would help us all know what we can and can not do.
|
|

Formula Problem

HI All,

I have made a formula in the formula field.
How can I make use of that formula to the report?
And other question,
is the syntax of the sql expression same as the syntax of sql
and what will it return and how to apply on the report?

Thanks for answer my stupid questionhi, :wave:
To use the formula in the report..drag it and place it whereever u want to display it...if i am right?

Yes the syntax of the sql expresstion is same as sql..but in where condition if u want to use any fields in the report..dont type it urself..just double click the field from the report fields in the formula editor..

Regards,
Rohini :thumb:|||Thanks for your reply

But I still don't know how to use the sql expression field
Can you show me a step by step example for me?

Thanks~~~~

Friday, March 23, 2012

Formatting syntax

Hi,

I am trying to convert an MS Access query to SQL script.The query builds a 16 digit field by combining 3 different columns.

access query

Select

"SP"& Format([CusNum],"000")& " "& Format$([InVoiceNum],"00000000") & "-" & Format$(Pizza,"00") AS RefNo,

From PurchaseOrder

RefNo

SP053 00000001-00

SP053 00000010-00

SP05314556895-00

SQL query to replace access query

Select

'SP'+Isnull(Cast(CusNumasvarchar(3)),'000')+''+Isnull(Cast(InVoiceNumasvarchar(8)),'00000000')+'-'+Isnull(Cast(PIasvarchar(2)),'00')

From dbo.PurchaseOrder

SP0531-0

SP05310-0

SP05314556895-00

I need some help in putting together a query that will give me the same results as produced by the access query.If InvoiceNum is less than 8 digits long I don’t know how to pad the field with 0000 to get it to be desired length.

Thanks for your help.

Nats

Nats:

Maybe something like this:

declare @.aNumber integer set @.aNumber = 715

select @.aNumber as [Input Number],
right ('0000000' + convert(varchar(8), @.aNumber), 8) as [formatted Number]

Input Number formatted Number
-
715 00000715

( Bemoaning my rustiness at Access; I wrote part of Access 97 Unleashed 2nd Ed, but I haven't used Access really since the previous millenium -- SHEESH! )

|||

Try the example below.

Chris

SELECT 'SP'

+ RIGHT('000' + ISNULL(CAST([CusNum] AS VARCHAR(3)), ''), 3)

+ ' '

+ RIGHT('00000000' + ISNULL(CAST([InVoiceNum] AS VARCHAR(8)), ''), 8)

+ '-'

+ RIGHT('00' + ISNULL(CAST(PI AS VARCHAR(2)), ''), 2)

FROM dbo.PurchaseOrder

--Note that PI should be in square brackets, however for some reason when I do this in the forum I end up with a piece of pizza, like so: Pizza

|||

Awesome works great...

Thanks a bunch!

Friday, February 24, 2012

Format Datetime in SQL syntax

Hi,
Does anyone know how I can format DateTme value in sql database to Short
DateTime using SQL syntax?
Thank you,
SunnyDo you mean you want to change the data type of the column from DateTime
to smalldatetime? Or you would like the returned results of a query to
have the datetime column with less information displayed.
Simon Worth
Sansanee wrote:
> Hi,
> Does anyone know how I can format DateTme value in sql database to Short
> DateTime using SQL syntax?
> Thank you,
> Sunny
>|||To change the ACTUAL datatype persisted (stored) in the database, use the
Cast operator, but ensure that all the actual date values are between 1 jan
1900 and 6 Jun 2079.
If you just want to format the output of a query, (and you can;t or don't
want to o this on client) you can use Convert() function and convert to a
varchar(), using one of a group of various format types Look up COnvert in
Books OnLine...
"Sansanee" wrote:

> Hi,
> Does anyone know how I can format DateTme value in sql database to Short
> DateTime using SQL syntax?
> Thank you,
> Sunny
>
>|||I recommend you check out:
http://www.karaszi.com/SQLServer/info_datetime.asp
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Sansanee" <sansanee@.nospam.com> wrote in message news:elIrk2xNFHA.3880@.tk2msftngp13.phx.gb
l...
> Hi,
> Does anyone know how I can format DateTme value in sql database to Short
> DateTime using SQL syntax?
> Thank you,
> Sunny
>|||Thank you. It works!
Sunny
"CBretana" <cbretana@.areteIndNOSPAM.com> wrote in message
news:56BDBAEA-F16B-4447-9145-E70699BE6AEC@.microsoft.com...
> To change the ACTUAL datatype persisted (stored) in the database, use the
> Cast operator, but ensure that all the actual date values are between 1
jan
> 1900 and 6 Jun 2079.
> If you just want to format the output of a query, (and you can;t or don't
> want to o this on client) you can use Convert() function and convert to a
> varchar(), using one of a group of various format types Look up COnvert in
> Books OnLine...
>
> "Sansanee" wrote:
>

Format Date in GroupBy query

What is the syntax for a query that will give me the Count of [PartID]
shipped each month. I think I need to do a Count on PK_ID and Group By the
DateShipped but how do I format the date. I tried using DateName but I can
only get it to work if I split out the Year and month. Thanks for the help.
The raw data looks like
PK_IDPartIDDateShipped
1KLP098A2005-04-11 10:59:05
2PLL907C2005-04-12 10:43:03
3LPK761F2005-05-15 10:23:07
And I want the output to be
MonthPartsShipped
Mar-20052
May-20051
On Thu, 14 Apr 2005 16:13:02 -0700, J wrote:

>What is the syntax for a query that will give me the Count of [PartID]
>shipped each month. I think I need to do a Count on PK_ID and Group By the
>DateShipped but how do I format the date. I tried using DateName but I can
>only get it to work if I split out the Year and month. Thanks for the help.
>The raw data looks like
>PK_IDPartIDDateShipped
>1KLP098A2005-04-11 10:59:05
>2PLL907C2005-04-12 10:43:03
>3LPK761F2005-05-15 10:23:07
>And I want the output to be
>MonthPartsShipped
>Mar-20052
>May-20051
Hi J,
With no DDL ans sample data to go on (see www.aspfaq.com/5006), this is
of course just guesswork - but you might want to try:
SELECT SUBSTRING(CONVERT(varchar(11), DateShipped, 106), 4, 8) AS
Month,
COUNT(*) AS PartsShipped
FROM YourTable
GROUP BY SUBSTRING(CONVERT(varchar(11), DateShipped, 106), 4, 8)
Best, Hugo
(Remove _NO_ and _SPAM_ to get my e-mail address)

Sunday, February 19, 2012

Format a float number

Hi
I am new to reporting servcies. I am wondering about the syntax I can use
to format a field in the report. The field is summing up a float column, and
I want only two decimals after the comma to be displayed.
This is the Value: =Sum(Fields!Samtals.Value)
What can I put in the format propertie for this field so a number like
123,4325345 becomes 123,42?Textboxes have a FormatCode property which allows you to specify a .NET
formatcode. For you particular example you would use N2 which gives you 2
decimals.
More details on formatcodes can be found on MSDN:
*
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconstandardnumericformatstrings.asp
*
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconcustomnumericformatstrings.asp
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Ágúst Valgarð" <gstValgar@.discussions.microsoft.com> wrote in message
news:FCCBD2DE-858A-41E0-924D-282854ED6BC7@.microsoft.com...
> Hi
> I am new to reporting servcies. I am wondering about the syntax I can use
> to format a field in the report. The field is summing up a float column,
and
> I want only two decimals after the comma to be displayed.
> This is the Value: =Sum(Fields!Samtals.Value)
> What can I put in the format propertie for this field so a number like
> 123,4325345 becomes 123,42?
>