[vicsireland] Re: DatePart function in SQL
- From: "Tony Murray" <Tony.G.Murray@xxxxxx>
- To: <vicsireland@xxxxxxxxxxxxx>
- Date: Thu, 14 Jun 2007 15:34:39 +0100
Hi Robbie,
What Database Management System are you using?
The below is standard TSQL, and as such, works fine in SQLServer.
The only major difference between Embedded SQL and Direct SQL is that
embedded SQL is contained within another program's code... like Java or C
for instance. As far as I know, there are no differences between the syntax
of Direct and Embedded SQL. Both are primarily concerned with executing
queries.
'Date isn't recognised'? I don't get that really. getdate() returns the
current date, and datepart() chops it up.
Another option might be to try datename(), but if datepart() doesn't work
for ya... I don't think datename will either.
I assume the field f1 you refer to contains records 1 to 52, to represent
the weeks of the year?
Cheers,
Tony
----- Original Message -----
From: "Sandberg, Robert" <robert.sandberg@xxxxxxx>
To: <vicsireland@xxxxxxxxxxxxx>
Sent: Thursday, June 14, 2007 2:49 PM
Subject: [vicsireland] Re: DatePart function in SQL
Hi Tony!
I've tried that but GetDate isn't recognised. It works in embedded SQL
code but apparently not in a query. Any other ideas?
Cheers,
Robbie
-----Original Message-----
From: vicsireland-bounce@xxxxxxxxxxxxx
[mailto:vicsireland-bounce@xxxxxxxxxxxxx] On Behalf Of Tony Murray
Sent: Donnerstag, 14. Juni 2007 14:19
To: vicsireland@xxxxxxxxxxxxx
Subject: [vicsireland] Re: DatePart function in SQL
Hi,
Datepart only returns numeric values, so whatever is contained within f1
will need to be of a similar datatype.
With that in mind, the following will compare the contents of f1 with
the
numeric value of the current week of the current year...
WHERE f1 = datepart(wk, getdate())
Cheers,
Tony
----- Original Message -----
From: "Sandberg, Robert" <robert.sandberg@xxxxxxx>
To: <vicsireland@xxxxxxxxxxxxx>
Sent: Thursday, June 14, 2007 12:41 PM
Subject: [vicsireland] DatePart function in SQL
Hi folks!
Can someone help me with the syntax for DatePart in a where clause? Just
like "where f1 = date()". But in stead of using the current date as a
filter criteria, I want to use the current week.
I can use DatePart as an argument to format date fields into calendar
weeks, but I can't make it work as a function of its own. Any
suggestions?
Cheers,
Robbie
******************************************************
This document is strictly confidential and is intended for use by the
addressee unless otherwise indicated.
This email has been scanned by an external email security system.
Allied Irish Banks
AIB and AIB Group are registered business names of Allied Irish Banks
p.l.c. Allied Irish Banks, p.l.c. is regulated by the Financial
Regulator. Registered Office: Bankcentre, Ballsbridge, Dublin 4. Tel: +
353 1 6600311; Registered in Ireland: Registered No. 24173
******************************************************
******************************************************
This document is strictly confidential and is intended for use by the addressee
unless otherwise indicated.
This email has been scanned by an external email security system.
Allied Irish Banks
AIB and AIB Group are registered business names of Allied Irish Banks p.l.c.
Allied Irish Banks, p.l.c. is regulated by the Financial Regulator. Registered
Office: Bankcentre, Ballsbridge, Dublin 4. Tel: + 353 1 6600311; Registered in
Ireland: Registered No. 24173
******************************************************
- Follow-Ups:
- [vicsireland] Re: DatePart function in SQL
- From: Sandberg, Robert
- References:
- [vicsireland] Re: DatePart function in SQL
- From: Sandberg, Robert
Other related posts:
- » [vicsireland] DatePart function in SQL
- » [vicsireland] Re: DatePart function in SQL
- » [vicsireland] Re: DatePart function in SQL
- » [vicsireland] Re: DatePart function in SQL
- » [vicsireland] Re: DatePart function in SQL
- » [vicsireland] Re: DatePart function in SQL
- [vicsireland] Re: DatePart function in SQL
- From: Sandberg, Robert
- [vicsireland] Re: DatePart function in SQL
- From: Sandberg, Robert