If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Date to timestamp conversion

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-07-12, 16:50
jeevana jeevana is offline
Registered User
 
Join Date: Jul 2011
Posts: 15
Question Date to timestamp conversion

Hi,

I need to convert date of this format 01/05/2012 11:28:42 to timestamp in mysql.

Currently TO_TIMESTAMP is been used for oracle .
I need to change the above dateformat to timestamp and save the same to DB.

Any immediate help on this is higl appreciated.

Regards,
Jeevana.
Reply With Quote
  #2 (permalink)  
Old 01-07-12, 17:09
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
whether 01/05/2012 11:28:42 represents january 5th 2012 or may 1st 2012, only you can say

but to do anything with it, you must convert it first to an actual mysql datetime, and you need to use the STR_TO_DATE function for this

then, once that's working, you can use UNIX_TIMESTAMP to convert it to an integer, if that's what you were after
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 01-10-12, 03:35
jeevana jeevana is offline
Registered User
 
Join Date: Jul 2011
Posts: 15
Would the same function work for Derby database also.
Reply With Quote
  #4 (permalink)  
Old 01-10-12, 03:54
jeevana jeevana is offline
Registered User
 
Join Date: Jul 2011
Posts: 15
Question What is the function for the Conversion of Date to Timestamp in Derby

Hi,

I need to convert date of this format 01/05/2012 11:28:42 to timestamp in Derby.
I need to change the above dateformat to timestamp and save the same to DB.

Currently Iam using STR_TO_DATE in mysql.Pls let me know if the same thing holds good for Derby also.


Any immediate help on this is highly appreciated.

Regards,
Latha.
Reply With Quote
  #5 (permalink)  
Old 01-10-12, 07:41
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
Quote:
Originally Posted by jeevana View Post
Currently Iam using STR_TO_DATE in mysql.Pls let me know if the same thing holds good for Derby also.
i have no idea

what happened when you tested it?
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #6 (permalink)  
Old 01-10-12, 08:14
jeevana jeevana is offline
Registered User
 
Join Date: Jul 2011
Posts: 15
Ya,its working fine for MySql.Thanks a lot.
Reply With Quote
  #7 (permalink)  
Old 01-10-12, 08:30
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
i meant, what happened when you tested it in derby?

i checked Built-in functions and i don't see it listed, so you will have to use DATE() and a series of SUBSTR() calls
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Tags
timestamp date difference

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

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