This should be doable, but how can I extract the day of the week from a field containing data in date format with Netezza SQL? I can write the following query:
SELECT date_part('day',a.report_dt) as report_dt FROM table as a
but that gives me the day of the month.
thanks for any help
Below are the some of the commonly used Netezza date functions. Returns the interval between two timestamps. Used to calculate the exact age. If you specify a single argument, the function returns the interval between the current time and the specified timestamp Truncates the date specified for date to the precision specified by units.
How To Get Day Of Week In SQL Server? Sometimes we need to get the day of week in name or number. SQL Server has a couple of inbuilt functions to get the day of week from the given date. To get the name of the day of week, you can use DATENAME function and to get the number of the day of week, you can use DATEPART function.
IBM® Netezza® SQL interval support is nonstandard. Extracts the subfield represented by units from the date/time value, interval, or duration specified for col .
Sometimes we need to get the day of week in name or number. SQL Server has a couple of inbuilt functions to get the day of week from the given date. To get the name of the day of week, you can use DATENAME function and to get the number of the day of week, you can use DATEPART function. Example.
The below queries give day numbers for any week,month,year for a particular date.
--Day of Week
SELECT EXTRACT(dow FROM report_dt) FROM table;
--Day of Month
SELECT DATE_PART('day', report_dt) FROM table;
--Day of Year
SELECT EXTRACT(doy FROM report_dt) FROM table;
Netezza is just ANSI SQL, originally derived from PostgreSQL. I'd expect this to work.
select extract(dow from a.report_dt) as report_dt
from table as a
Returns values should range from 0 to 6; 0 is Sunday. You might expect that to be an integer, but in PostgreSQL at least, the returned value is a double-precision floating point.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With