• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

how to print a date with hours minutes and seconds in a pl sql stored procedure in oracle

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
FIRTS QUESTION

how can i print a date with hours minutes and seconds in a pl sql stored procedure in oracle, because i have a column in my table and it's type is DATE, when i do a select for this column I get the entire date with minutes hours and seconds,

but when i try to print that date in a stored procedure using this

DBMS_OUTPUT.PUT_LINE('date value before my if : '|| to_date(my_date, 'DD-MM-YYYY HH24:MI:SS'));



that prints me only the date without the hours minutes and seconds. i'm getting that my_date from a select into like this

select
to_date(ni.my_date, 'DD-MM-YYYY HH24:MI:SS') , ni.id_ni into my_date_iterator, id_iterator
from


i'm doing this print inside a loop but i dont think that that have something to do.


why when i do a normal slect it brings me the hours, minutes and seconds, but when i do a select into inside a stored procedure it dont print me the seconds and minutes and hours, i think that when i do the select into my date variable it brings me the entire date with seconds and minutes but i dont know why it dont print them


SECOND QUESTION

how can I compare two dates that have the same day, month and year.. but they have diferent hours, minutes and seconds

I have this stroe procedure but when i compare the dates it says they are the same:



when i run that stored it says that the dates are equals and it not says that the bigger date is bigger
 
author
Posts: 42
1
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jhon,

If your column type is DATE, why are you using to_date? This function converts a string to a date.

Why don't you try getting my_date just with:

And then use the to_char function like this:


About your second question, I think it's the same problem. bigger_date and minor_date are dates, you don't need to use the to_date function in the if condition, compare them directly:

 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic