IT Community - Software Programming, Web Development and Technical Support

Date Operations in different databases

This is a discussion on Date Operations in different databases within the Database Support forums, part of the Web Development category; Date Operations in different databases 1. Microsoft SQL Server SELECT GETDATE() 2. MySQL [retrieving the date but not time] SELECT ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > Database Support

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 12-04-2007, 01:28 AM
srikumar_l srikumar_l is offline
D-Web Sr.Programmer
 
Join Date: Aug 2007
Posts: 196
srikumar_l is on a distinguished road
Default Date Operations in different databases

Date Operations in different databases

1. Microsoft SQL Server

SELECT GETDATE()


2. MySQL [retrieving the date but not time]

SELECT CURDATE();

3. MySQL [retrieving date and time]

SELECT NOW();

4. Oracle

SELECT SYSDATE FROM dual;

5. PostgreSQL

SELECT CURRENT_DATE;
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 12-04-2007, 02:59 AM
priyan priyan is offline
D-Web Sr.Programmer
 
Join Date: Mar 2007
Posts: 133
priyan is on a distinguished road
Default Re: Date Operations in different databases

Quote:
2. MySQL [retrieving the date but not time]

SELECT CURDATE();
You can use SYSDATE() function to get the date and time values. Sysdate() will return the date and time in 'YYYY-MM-DD HH:MM:SS' format.
__________________
Keep smiling...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 12-04-2007, 06:01 AM
Murali Murali is offline
D-Web Master
 
Join Date: Feb 2007
Location: India-Chennai.
Posts: 386
Murali is on a distinguished road
Send a message via AIM to Murali
Default Re: Date Operations in different databases

hi techies,

can we able to set default current date for a table column in MySQL?
__________________
-Murali..
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 12-04-2007, 07:59 AM
priyan priyan is offline
D-Web Sr.Programmer
 
Join Date: Mar 2007
Posts: 133
priyan is on a distinguished road
Default Re: Date Operations in different databases

Hi, check out this...

Code:
mysql> create table tbl_test (id integer, dt timestamp default now());

mysql> insert into tbl_test(id) values(1);

mysql> insert into tbl_test(id) values(2);

mysql> SELECT * FROM tbl_test;
+------+---------------------+
| id   | dt                  |
+------+---------------------+
|    1 | 2007-12-04 20:38:50 |
|    2 | 2007-12-04 20:38:51 |
+------+---------------------+
2 rows in set (0.00 sec)

Hope this is your requirement ...
__________________
Keep smiling...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert a date in milliseconds back to a date string itbarota HTML, CSS and Javascript Coding Techniques 2 03-03-2008 09:03 PM
How can I show the documents last modified date in the format: month, date, year, tim Pvinothkumar HTML, CSS and Javascript Coding Techniques 3 12-28-2007 05:58 AM
How can I compare a date in a string with todays date? itbarota HTML, CSS and Javascript Coding Techniques 2 12-18-2007 11:02 PM
String Operations using different databases srikumar_l Database Support 0 12-05-2007 03:27 AM
How to convert a date to a globally accepted date format, in DOT NET 2005? Archer C# Programming 1 07-25-2007 03:21 AM


All times are GMT -7. The time now is 04:43 AM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0