dateserial in T-SQL?

Results 1 to 2 of 2

Thread: dateserial in T-SQL?

  1. #1
    Join Date
    Dec 1969

    Default dateserial in T-SQL?

    I want to set a variable equal to the first of next month in T-SQL:<BR><BR>@nextmonth=dateserial(1,month(dateadd( "m",1,now)),year(dateadd("m",1,now)))<BR><BR>B ut there is no dateserial function in T-SQL. What&#039;s the equivalent. BOL no help.<BR><BR>Anyone?

  2. #2
    Join Date
    Dec 1969

    Default Best you can do is DateAdd

    DateAdd(month,1,<BR> DateAdd(day,1-Day(getDate()),getDate())<BR> )<BR><BR>Does that make sense?<BR><BR>We start with today (e.g., 22 May 2003). We add one day and subtract today&#039;s day number (so we dateadd +1-22 or -21). That gets us to 1 May 2003. Then we add 1 month to that.<BR><BR>What I don&#039;t know is if that will get you <BR> 1 Jun 2003 9:08:10 PM<BR>or just<BR> 1 Jun 2003<BR>You&#039;ll have to experiment to find out.<BR><BR>

Posting Permissions

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