Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Closed Thread
 
Thread Tools Display Modes
  #1  
Old 06-18-2018, 04:23 AM
rmt rmt is offline
Senior Member
 
Join Date: Jun 2013
Posts: 272
Default SQL SERVER ERROR: Explicit conversion from data type numeric to time is not allowed.

Dear Expert,

I am getting an error "Explicit conversion from data type numeric to time is not allowed" while trying to convert Numeric Value to Time.

Actually I am getting 10:00:00.0000000 and 5.00 respectively for the variables @InTime and @WorkHours while running below query:

DECLARE @InTimeDate DateTime
SET @InTimeDate='1899-12-30 10:00:00.000'
Declare @InTime Time
Declare @WorkHours Numeric(4,2)
SET @WorkHours=5.00
SET @InTime=CAST(@InTimeDate AS TIME)
SELECT @InTime,@WorkHours

Now, while running the below query, I am getting an error:
SET @InTime=@InTime+CAST(@WorkHours AS TIME)

Actually I want the value of 15:00:00.0000000 for @InTime.

Kindly suggest.
__________________
Rmt
  #2  
Old 06-18-2018, 08:38 AM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,292
Default

Code:
SET @InTime=DateAdd(hour,@WorkHours,@InTimeDate)
  #3  
Old 06-19-2018, 03:41 PM
rmt rmt is offline
Senior Member
 
Join Date: Jun 2013
Posts: 272
Default

dear Norrit,
tnx a lot..its working.
__________________
Rmt
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 08:18 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2018, vBulletin Solutions, Inc.