cast date code example

Example 1: sql cast as

CAST('2006-04-25T15:50:59.997' AS date) AS Date,  

CAST('2006-04-25T15:50:59.997' AS time) AS Time,  

CAST('2006-04-25T15:50:59.997' AS datetime) AS Datetime,

Example 2: select CONVERT(NUMber(10,2),dailybroadbandusagedsmbyte)

select CONVERT(NUMber(10,2),dailybroadbandusagedsmbyte)

Example 3: sql cast to integer

-- NOTE: this is for SQL-Oracle specifically

/*
<...> : Your personal entry
*/

-- syntax:
CAST(<variable> as <variable-type>) -- in this case: <variable-type> = INTEGER

-- example:
SELECT CAST(MEMBER_NO as INTEGER)
FROM DUAL;

Example 4: sql value of string

-- Specifically for Oracle

-- EXAMPLE
CAST('732.98' AS INT)

/* SYNTAX
CAST(<value_to_cast> AS <data_type_to_cast_to>)
*/

Tags:

Sql Example