Tuesday, March 20, 2012

Converting

Hi, can you help me converting some queries from ASP application Oracle to
SQL SERVER 2000?
example:
1) " and p.DATACAD <= to_date('"& BDATACAD2 &" 23:59:59','dd/mm/yyyy
hh24:mi:ss')"
2) " WHERE TO_CHAR(DATA_HORAS,'MM/YYYY') ='"&SEL_PER&"'"
How can it be converted to SQL Server?Hi
You can use the convert function to format dates as text or cast to cast
between datatypes. If your datestring is in a "safe" format e.g CCYYMMDD or
'CCYY-MM-DDTHH:MM:SS.NNN then you could let it do an implicit conversion e.g.
and p.DATACAD < '20071120'
If you specify a date with no time it will default to midnight 00:00:00.000
Datetime granularity is 3.33 milliseconds and smalldatetime is accurate to 1
minute.
You can try this out using Query Analyser or Management studio e.g.
SELECT CAST('11:31:08.000' AS datetime),
CAST('11:31:08.000' AS smalldatetime),
CAST('20071120' AS datetime),
CAST('20071120' AS smalldatetime),
CAST('2007-11-20T23:59:59.995' AS smalldatetime),
CAST('2007-11-20T23:59:59.995' AS datetime),
CAST('2007-11-20T23:59:59.990' AS datetime),
CAST('2007-11-20T23:59:59.992' AS datetime),
CAST('2007-11-20T23:59:59.993' AS datetime),
CAST('2007-11-20T23:59:59.994' AS datetime),
CAST('2007-11-20T23:59:59.996' AS datetime),
CAST('2007-11-20T23:59:59.997' AS datetime),
CAST('2007-11-20T23:59:59.998' AS datetime),
CAST('2007-11-20T23:59:59.999' AS datetime)
"Paulo" wrote:
> Hi, can you help me converting some queries from ASP application Oracle to
> SQL SERVER 2000?
> example:
> 1) " and p.DATACAD <= to_date('"& BDATACAD2 &" 23:59:59','dd/mm/yyyy
> hh24:mi:ss')"
> 2) " WHERE TO_CHAR(DATA_HORAS,'MM/YYYY') ='"&SEL_PER&"'"
> How can it be converted to SQL Server?
>
>

No comments:

Post a Comment