Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

645
Vistas
How many payments happened on Monday from payment _date column? The below code giving me zero count
SELECT COUNT(*)
FROM payment
WHERE(TO_CHAR(payment_date, 'Day')) = 'Monday'
over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

TO_CHAR(payment_date, 'Day') returns a string padded with spaces ('Monday ').

To suppress the spaces, use the FM modifier ("fill mode")

SELECT COUNT(*)
FROM payment
WHERE (TO_CHAR(payment_date, 'FMDay')) = 'Monday'

alternatively be explicit and use trim()

SELECT COUNT(*)
FROM payment
WHERE (trim(TO_CHAR(payment_date, 'Day'))) = 'Monday'

However, I would recommend to not use locale specific values (on my computer the above would always return 0 as I have a different language setting).

Using numbers e.g. with extract(isodow from ..) is much more reliable.

over 4 years ago · Santiago Trujillo Denunciar

0

Use dow(day of week).
The day of the week (0 - 6; Sunday is 0) (for timestamp values only)

SELECT COUNT(*)
FROM payment
WHERE EXTRACT(DOW FROM payment_date)= 1;

For more details on the dow check out the documentation.

over 4 years ago · Santiago Trujillo Denunciar

0

SELECT COUNT(*) AS day_of_payment 
FROM payment
WHERE TO_CHAR (payment_date,'DAY') = 'MONDAY   '

Considering that "blank padded to 9 characters", which means instead of returning 'Monday' it returns 'Monday ' with extra spaces to fill up at least 9 spaces.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda