Need help in SQL SERVER

Results 1 to 2 of 2

Thread: Need help in SQL SERVER

  1. #1
    Join Date
    Dec 1969

    Default Need help in SQL SERVER

    how to add month to a date field

  2. #2
    Join Date
    Dec 1969

    Default Right From Documentation...

    DATEADD<BR>Returns a new datetime value based on adding an interval to the specified date.<BR><BR>Syntax<BR>DATEADD ( datepart , number, date ) <BR><BR>Arguments<BR>datepart<BR><BR>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™.<BR><BR>Datepart Abbreviations <BR>Year yy, yyyy <BR>quarter qq, q <BR>Month mm, m <BR>dayofyear dy, y <BR>Day dd, d <BR>Week wk, ww <BR>Hour hh <BR>minute mi, n <BR>second ss, s <BR>millisecond ms <BR><BR><BR>number<BR><BR>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.<BR><BR>date<BR><BR>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. <BR><BR>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.<BR><BR>Return Types<BR>Returns datetime, but smalldatetime if the date argument is smalldatetime.<BR><BR>Examples<BR>This example prints a listing of a time frame for titles in the pubs database. This time frame represents the existing publication date plus 21 days.<BR><BR>USE pubs<BR>GO<BR>SELECT DATEADD(day, 21, pubdate) AS timeframe<BR>FROM titles<BR>GO<BR><BR>Here is the result set:<BR><BR>timeframe <BR>--------------------------- <BR>Jul 3 1991 12:00AM <BR>Jun 30 1991 12:00AM <BR>Jul 21 1991 12:00AM <BR>Jul 13 1991 12:00AM <BR>Jun 30 1991 12:00AM <BR>Jul 9 1991 12:00AM <BR>Mar 14 1997 5:09PM <BR>Jul 21 1991 12:00AM <BR>Jul 3 1994 12:00AM <BR>Mar 14 1997 5:09PM <BR>Nov 11 1991 12:00AM <BR>Jul 6 1991 12:00AM <BR>Oct 26 1991 12:00AM <BR>Jul 3 1991 12:00AM <BR>Jul 3 1991 12:00AM <BR>Nov 11 1991 12:00AM <BR>Jul 3 1991 12:00AM <BR>Jul 3 1991 12:00AM <BR><BR>KLC

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts