Avatar billede kovalt Nybegynder
12. maj 2003 - 17:11 Der er 4 kommentarer og
1 løsning

lægge tal til dato

Hej

  Er det muligt at ligge et tal til en "SMALLDATETIME".

ex.

12-05-2003 13:00:00 + 100 = 12-05-2003 14:40:00

/kovalt
Avatar billede pierrehusted Nybegynder
12. maj 2003 - 17:22 #1
Ja, f.eks. sådan her :

DateAdd('mi', 100, '12-05-2003 13:00:00')
Avatar billede pierrehusted Nybegynder
12. maj 2003 - 17:23 #2
Nej, sådan her:

DateAdd(mi, 100, '12-05-2003 13:00:00')
Avatar billede kovalt Nybegynder
12. maj 2003 - 17:23 #3
hvad står mi for?
Avatar billede pierrehusted Nybegynder
12. maj 2003 - 17:24 #4
minutter......

Fra BOOKS ONLINE:

DATEADD
Returns a new datetime value based on adding an interval to the specified date.

Syntax
DATEADD ( datepart , number, date )

Arguments
datepart

Is the parameter that specifies on which part of the date to return a new value. The table lists the dateparts and abbreviations recognized by Microsoft® SQL Server™.

Datepart Abbreviations
Year yy, yyyy
quarter qq, q
Month mm, m
dayofyear dy, y
Day dd, d
Week wk, ww
Hour hh
minute mi, n
second ss, s
millisecond ms


number

Is the value used to increment datepart. If you specify a value that is not an integer, the fractional part of the value is discarded. For example, if you specify day for datepart and1.75 for number, date is incremented by 1.

date

Is an expression that returns a datetime or smalldatetime value, or a character string in a date format. For more information about specifying dates, see datetime and smalldatetime.

If you specify only the last two digits of the year, values less than or equal to the last two digits of the value of the two digit year cutoff configuration option are in the same century as the cutoff year. Values greater than the last two digits of the value of this option are in the century that precedes the cutoff year. For example, if two digit year cutoff is 2049 (default), 49 is interpreted as 2049 and 2050 is interpreted as 1950. To avoid ambiguity, use four-digit years.

Return Types
Returns datetime, but smalldatetime if the date argument is smalldatetime.
Avatar billede kovalt Nybegynder
12. maj 2003 - 17:30 #5
tenx
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Computerworld tilbyder specialiserede kurser i database-management

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester