Click here to Skip to main content
15,890,123 members
Home / Discussions / Database
   

Database

 
GeneralRe: How to import xml to SQL? Pin
thienvan21-Apr-11 16:06
thienvan21-Apr-11 16:06 
GeneralRe: How to import xml to SQL? Pin
Prasanta_Prince21-Apr-11 22:59
Prasanta_Prince21-Apr-11 22:59 
QuestionGet Month - Common Function for SQL Server & Oracle Pin
NTheOne20-Apr-11 0:03
NTheOne20-Apr-11 0:03 
AnswerRe: Get Month - Common Function for SQL Server & Oracle Pin
Mycroft Holmes20-Apr-11 12:58
professionalMycroft Holmes20-Apr-11 12:58 
AnswerRe: Get Month - Common Function for SQL Server & Oracle Pin
Bernhard Hiller20-Apr-11 21:15
Bernhard Hiller20-Apr-11 21:15 
QuestionRe: Get Month - Common Function for SQL Server & Oracle Pin
Eddy Vluggen20-Apr-11 23:31
professionalEddy Vluggen20-Apr-11 23:31 
AnswerRe: Get Month - Common Function for SQL Server & Oracle Pin
jschell21-Apr-11 8:19
jschell21-Apr-11 8:19 
QuestionIs it possible to pass datepart abbreviations to a function? Pin
fd975019-Apr-11 23:16
professionalfd975019-Apr-11 23:16 
Hi Everyone,

First: what is desired

Most of us probably know this trick for clipping of the time part of a DATETIME value (at least you can find it in an awful lot of places on the internet):

@Date = DATEADD (DD, DATEDIFF (DD, 0, @Date), 0)

It will simply get you a new DATETIME value with the time set at 00:00:00.

If you use any other datepart abbreviation you get the same but with the date or time clipped at whatever you selected.
Example: if you use MI you get your DATETIME clipped at the minute value (i.e: seconds and milliseconds set to 0).

It is very useful but it would be even more useful if it were possible to put this in a function.
Then it would be possible to call "my_f_cliptime (XXX, DateTimeValue)" in which XXX (note the lack of quotes) would be the datepart abbreviation you want to pass to the function for further use within the DATEADD and DATEDIFF operations.

The problem is that DATEADD and DATEDIFF do support datepart abbreviations but you have to include them in your source code directly.
Also: you can't pass those abbreviation as strings because DATEADD and DATEDIFF do not accept them that way.

So here is the question: does anyone know of a way to pass the datepart abbreviations (there does not seem to be a datepart variable type) or, alternatively, a way to convert equivalent strings to datepart abbreviations before passing them to DATEADD and DATEDIFF ?

For the moment I suppose there is'nt but then again you never know.

Bye

PS: I am generally not very curious but if possible I prefer knowing everything
AnswerRe: Is it possible to pass datepart abbreviations to a function? Pin
J4amieC20-Apr-11 0:59
J4amieC20-Apr-11 0:59 
AnswerRe: Is it possible to pass datepart abbreviations to a function? Pin
fd975020-Apr-11 1:31
professionalfd975020-Apr-11 1:31 
GeneralRe: Is it possible to pass datepart abbreviations to a function? Pin
Mycroft Holmes20-Apr-11 12:55
professionalMycroft Holmes20-Apr-11 12:55 
GeneralRe: Is it possible to pass datepart abbreviations to a function? Pin
J4amieC20-Apr-11 21:49
J4amieC20-Apr-11 21:49 
GeneralRe: Is it possible to pass datepart abbreviations to a function? Pin
Mycroft Holmes20-Apr-11 22:08
professionalMycroft Holmes20-Apr-11 22:08 
GeneralRe: Is it possible to pass datepart abbreviations to a function? Pin
J4amieC20-Apr-11 22:14
J4amieC20-Apr-11 22:14 
GeneralRe: Is it possible to pass datepart abbreviations to a function? Pin
J4amieC20-Apr-11 22:17
J4amieC20-Apr-11 22:17 
AnswerRe: Is it possible to pass datepart abbreviations to a function? Pin
PIEBALDconsult20-Apr-11 3:02
mvePIEBALDconsult20-Apr-11 3:02 
GeneralRe: Is it possible to pass datepart abbreviations to a function? Pin
J4amieC20-Apr-11 3:18
J4amieC20-Apr-11 3:18 
GeneralRe: Is it possible to pass datepart abbreviations to a function? Pin
PIEBALDconsult20-Apr-11 14:50
mvePIEBALDconsult20-Apr-11 14:50 
AnswerRe: Is it possible to pass datepart abbreviations to a function? Pin
jschell20-Apr-11 8:08
jschell20-Apr-11 8:08 
QuestionUsing the same table more than once in a SQL View Pin
Etienne_12319-Apr-11 20:53
Etienne_12319-Apr-11 20:53 
AnswerRe: Using the same table more than once in a SQL View Pin
loveangel88819-Apr-11 21:13
loveangel88819-Apr-11 21:13 
AnswerRe: Using the same table more than once in a SQL View Pin
Wayne Gaylard19-Apr-11 21:20
professionalWayne Gaylard19-Apr-11 21:20 
GeneralRe: Using the same table more than once in a SQL View [modified] Pin
Etienne_12319-Apr-11 23:37
Etienne_12319-Apr-11 23:37 
AnswerRe: Using the same table more than once in a SQL View Pin
Mycroft Holmes20-Apr-11 12:52
professionalMycroft Holmes20-Apr-11 12:52 
QuestionCan't update table with expression field Pin
Muammar©19-Apr-11 7:48
Muammar©19-Apr-11 7:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.