• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Inserting date using SQL

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, what I'm trying to do is insert data into a database table. 'normal' info is inserted fine but what I need to do is have the current date inserted with the information also. There is a date field in the table but is there a method that allows the current date to be inserted with the rest of the info?
Thanks!
 
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See this as an example... I did it in oracle.... I hope it is applicable to other database as well, you change the function TO_DATE to corresponding function of database... Hope this helps...
 
shuzo monsoon
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ko, but I@m getting an error saying "today" is either a misplaced package name or a non existent entity. Any ideas?
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
today is a constant of the Date... U may set it in anywhere, b4 the code that I provided to you....
Maybe this might be helpful...
 
shuzo monsoon
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks again Ko, but now there's an error saying -
"The type of this expression, "int", is not a valid reference type in this context." and it refers to the line -
today.getDate().toString()
Is it because I'm trying to assign the date to a string?
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by shuzo monsoon:
Thanks again Ko, but now there's an error saying -
"The type of this expression, "int", is not a valid reference type in this context." and it refers to the line -
today.getDate().toString()


Try this...


Is it because I'm trying to assign the date to a string?


No, it means that we are changing the date object to be a string... Hope it's solved...
 
You will always be treated with dignity. Now, strip naked, get on the probulator and hold this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic