Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB SQL » View Thread |
Messages 1 to 4 of 4 total |
How to cast a variable to timestamp |
Fri, Jun 3 2011 5:18 AM | Permanent Link |
durumdara | Hi!
I search for a way to cast a procedure variable to time to add to another time variable. For example: set oldtime = current_timestamp; set min = ........ .... set timediff = cast (min as minute); set newtime = oldtime + timediff; How can I do it? I try with everything, for example: cast('00:' + cast(perc as varchar(2)) + ':00); But I don't found a solution to avoid "constant needed" error. Thanks: dd |
Fri, Jun 3 2011 5:38 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Welcome to the wonderful world of INTERVAL.
The syntax is totally different from DBISAM. You'll now need to do something like UPDATE table SET oldtime = oldtime +CAST( min as interval minute) Roy Lambert [Team Elevate] |
Fri, Jun 3 2011 12:26 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | << I search for a way to cast a procedure variable to time to add to another time variable. >> Use something like this: SCRIPT BEGIN DECLARE OldTime TIMESTAMP DEFAULT CURRENT_TIMESTAMP(); DECLARE MinDiff INTERVAL MINUTE DEFAULT INTERVAL '10' MINUTE; DECLARE NewTime TIMESTAMP; SET NewTime = OldTime + MinDiff; SET LOG MESSAGE TO 'Old Time: '+CAST(OldTime AS VARCHAR)+' '+ 'New Time: '+CAST(NewTime AS VARCHAR); END In general, don't use keywords like 'Min' for variable names, you'll get parsing errors because the parser will think that you're trying to use the MIN() aggregate function. -- Tim Young Elevate Software www.elevatesoft.com |
Fri, Jun 3 2011 1:55 PM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Tim
Well caught. I was reading it as an UPDATE statement but revisiting the OP it is a procedure. he's looking for. Roy Lambert |
This web page was last updated on Tuesday, April 30, 2024 at 03:55 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |