Jump to content



Photo

Oracle - SQL - First day of the current month

sql query oracle

  • Please log in to reply
3 replies to this topic

#1 ZeroFearX

ZeroFearX

    Neowinian

  • Tech Issues Solved: 2
  • Joined: 08-November 11

Posted 25 February 2014 - 18:09

Hello,

 

I am trying to generate an automated SQL Report that will always use the current first day of the month. Format: 'YYYY-MM-01'

 

Sadly I dont have the ability to create functions on the database and I do not know how else I can make this work. I saw "SYSDATE()" but I am not familiar with this enough to get it working.

 

Thank you




#2 FloatingFatMan

FloatingFatMan

    Resident Fat Dude

  • Tech Issues Solved: 1
  • Joined: 23-August 04
  • Location: UK

Posted 26 February 2014 - 21:46

It's been a loooong time since I touched Oracle, so possibly it's changed since, but this should work if I remember correctly...

 

SELECT TO_CHAR(TRUNC(SYSDATE,'MM'),'YYYY-MON-DD HH24:MI') FROM dual;


#3 BGM

BGM

    Wibble Wobble™

  • Joined: 30-March 03
  • Location: Farnborough, UK

Posted 05 March 2014 - 12:30

one of these should do it...

select
  trunc(current_timestamp, 'mm') 
  ,to_char(trunc(current_timestamp, 'mm'))
from dual


#4 FloatingFatMan

FloatingFatMan

    Resident Fat Dude

  • Tech Issues Solved: 1
  • Joined: 23-August 04
  • Location: UK

Posted 18 March 2014 - 13:58

@OP, did you resolve this in the end? Did mine or BGM's posts help?