Error message

Discussion in 'ASP .Net' started by bbawa1@yahoo.com, Jun 18, 2007.

  1. Guest

    Again thanks a lot but When I execute only this portion it gives me
    error

    Syntax error converting the varchar value '2d 0h 0m' to a column of
    data
    type int.

    My stored procedure is the following.

    Followed is the SQL Script and you can use this code in your SQL
    Function to
    get the difference and make function with StartDate and EndDate
    parameters
    and return the @Diff

    DECLARE @Day INT
    DECLARE @Hour INT
    DECLARE @Minute INT
    DECLARE @Start_Date DateTime
    DECLARE @End_Date DateTime
    SET @Start_Date = '6/13/2007 12:38 AM'
    SET @End_Date = '6/14/2007 11:59 PM'
    SET @Day = DATEDIFF( day, @Start_Date, @End_Date)
    SET @Hour = DATEDIFF(hour , @Start_Date, @End_Date)
    SET @Minute = DATEDIFF(minute , @Start_Date, @End_Date)
    SET @Minute = @Minute-(@HOUR* 60)
    SET @Hour = @Hour-(24* @Day)
    SET @Diff = CONVERT( Varchar, @Day) +'d ' + CONVERT(Varchar , @Hour) +
    'h '
    + CONVERT(Varchar , @Minute) +'m'
    PRINT
    'Difference : ' + @Diff
    , Jun 18, 2007
    #1
    1. Advertising

  2. On Jun 18, 9:42 pm, wrote:
    > Again thanks a lot but When I execute only this portion it gives me
    > error
    >
    > Syntax error converting the varchar value '2d 0h 0m' to a column of
    > data
    > type int.
    >
    > My stored procedure is the following.
    >
    > Followed is the SQL Script and you can use this code in your SQL
    > Function to
    > get the difference and make function with StartDate and EndDate
    > parameters
    > and return the @Diff
    >
    > DECLARE @Day INT
    > DECLARE @Hour INT
    > DECLARE @Minute INT
    > DECLARE @Start_Date DateTime
    > DECLARE @End_Date DateTime
    > SET @Start_Date = '6/13/2007 12:38 AM'
    > SET @End_Date = '6/14/2007 11:59 PM'
    > SET @Day = DATEDIFF( day, @Start_Date, @End_Date)
    > SET @Hour = DATEDIFF(hour , @Start_Date, @End_Date)
    > SET @Minute = DATEDIFF(minute , @Start_Date, @End_Date)
    > SET @Minute = @Minute-(@HOUR* 60)
    > SET @Hour = @Hour-(24* @Day)
    > SET @Diff = CONVERT( Varchar, @Day) +'d ' + CONVERT(Varchar , @Hour) +
    > 'h '
    > + CONVERT(Varchar , @Minute) +'m'
    > PRINT
    > 'Difference : ' + @Diff


    @Diff requires a value of type int


    > SET @Diff = CONVERT( Varchar, @Day) +'d ' + CONVERT(Varchar , @Hour) +

    'h ' + CONVERT(Varchar , @Minute) +'m'
    Alexey Smirnov, Jun 18, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?bWc=?=
    Replies:
    1
    Views:
    2,136
    Marshal Antony
    Feb 8, 2004
  2. =?Utf-8?B?bWc=?=

    Size of e-mail message - message.Body = msgText

    =?Utf-8?B?bWc=?=, Feb 10, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    564
    Chad Z. Hower aka Kudzu
    Feb 11, 2004
  3. - Steve -
    Replies:
    0
    Views:
    703
    - Steve -
    Jul 6, 2004
  4. tshad
    Replies:
    0
    Views:
    794
    tshad
    Jan 27, 2005
  5. Hari Om
    Replies:
    3
    Views:
    12,138
    Wendy S
    Oct 1, 2003
Loading...

Share This Page