Datadiff,datepart Problem!!!!!!!!!!!!!!!!!!!!!!!!!

Results 1 to 3 of 3

Thread: Datadiff,datepart Problem!!!!!!!!!!!!!!!!!!!!!!!!!

  1. #1
    !!!!!HELP!!!~SOS!!! Guest

    Default Datadiff,datepart Problem!!!!!!!!!!!!!!!!!!!!!!!!!

    What is the different betwwen them and how is function.<BR><BR>Actually I want to use either one function to compare the date and month between the record date and teh current date.<BR><BR>For eg., the record date is 2/25/69, and current date is 5/25/00. Now, i want to make comparison to the month and day only, so the result will be 3 months gap. That is. How to write it in ASP???? Thanks.<BR>

  2. #2
    Manoj & amit Guest

    Default RE: Datadiff,datepart Problem!!!!!!!!!!!!!!!!!!!!!

    You can use this function of MS-Sql server 7.0 to get what you want.....<BR>select datediff(month,&#039 2/24/69&#039,getdate()) from &#060;table Name&#062;

  3. #3
    Join Date
    Dec 1969

    Default RE: Datadiff,datepart Problem!!!!!!!!!!!!!!!!!!!!!

    datediff returns the difference between two dates; you specify the units for the difference (e.g., year, quarter, month, etc.)<BR><BR>datepart returns a portion of a date in the specified unit (year, month, day, etc...). It is intended to be a single function encapsulating other functions such as year, month, day, etc.<BR><BR>One possible solution to your problem would be to convert one of the dates to the same year as the other and use use datediff to return the difference in the desired units (i.e., months). Here&#039s an example (converting the record date the the same year as the current date):<BR><BR>dateFromDB = ...appropriate code to get date from DB...<BR>dateCurrent = Date()<BR>intYearDiff = DateDiff("yyyy", dateFromDB, dateCurrent)<BR>dateToCompare = DateAdd("yyyy", intYearDiff, dateFromDB)<BR>intMonthDiff = DateDiff("M", dateCurrent, DateToCompare)<BR><BR>HTH,<BR><BR>Marcus<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