Reputation: 41
I have data columns timestamp, message, etc., in a table.
Example :
column 1 - timestamp has '3/7/2013 9:30:40 AM'
column 2 - message has '6Q201303077981 ,MAR 07 2013 09:30:00,167,P,NYSE,CD,0000.0500,PARTIAL EXECUTION
,20130312,000006.35,000000.11,000005.25,0000127.0000,0000623.0000, ,0037.160000,0000000.0000,0000.000000,0037.160000,PEXE'
Now I need output as
column1 - timestamp as '3/7/2013 9:30:40 AM'
column2 - message as '3/7/2013 9:30:00 AM'
column3 - diff as 40
Please help on this query...
Upvotes: 0
Views: 1462
Reputation: 651
Actually you need to use a convert function to convert the varchar in a datetime datatype. Once you have this you can use a date function to see the difference.
For more details about convert please see the sybase manual here: http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.help.ase_15.0.blocks/html/blocks/blocks125.htm
For more details about the date diff function please see the sybase manual here: http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.help.ase_15.0.blocks/html/blocks/blocks137.htm
once you have found the correct functions you can do something like this:
select timestamp, convert(xxxxx), datediff(xxxx) from table
Upvotes: 1